From 2a4e2e048143100c6b8b78fc43d31664c2f1f72a Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 22 Feb 2015 20:02:04 +0000 Subject: [PATCH 01/71] Take decomp, install-sh and missing from gcc-gcc6809 so that exec09 will configure and build stand-alone. Add simple build instructions to README. --- README | 21 +- depcomp | 553 +++++++++++++++++++++++++++++++++++++++++++++++++++++ install-sh | 323 +++++++++++++++++++++++++++++++ missing | 360 ++++++++++++++++++++++++++++++++++ 4 files changed, 1255 insertions(+), 2 deletions(-) create mode 100755 depcomp create mode 100755 install-sh create mode 100755 missing diff --git a/README b/README index 2ae16b0..4bb6672 100644 --- a/README +++ b/README @@ -2,11 +2,26 @@ This is a rewrite of Arto Salmi's 6809 simulator. Many changes have been made to it. This program remains licensed under the GNU General Public License. +----------------------------------------------------------------- +Build and install (on Linux) + +you will need make, gcc, aclocal, automake and probably some other +stuff. Then: + +> ./configure +> make + +There is one executable, m6809-run. You can install it (make install) or +simply reference it explicitly. + +----------------------------------------------------------------- Input Files +----------------------------------------------------------------- Machines + The simulator now has the notion of different 'machines': which says what types of I/O devices are mapped into the 6809's address space and how they can be accessed. Adding support for @@ -40,10 +55,13 @@ that wants to have persistence. TODO : Would anyone be interested in a CoCo machine type? +----------------------------------------------------------------- Faults +====== - +----------------------------------------------------------------- Debugging +========= The simulator supports interactive debugging similar to that provided by 'gdb'. @@ -120,7 +138,6 @@ x ----------------------------------------------------------------- - Original README text from Arto: diff --git a/depcomp b/depcomp new file mode 100755 index 0000000..3510ab0 --- /dev/null +++ b/depcomp @@ -0,0 +1,553 @@ +#! /bin/sh +# depcomp - compile a program generating dependencies as side-effects + +scriptversion=2005-05-16.16 + +# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Originally written by Alexandre Oliva . + +case $1 in + '') + echo "$0: No command. Try \`$0 --help' for more information." 1>&2 + exit 1; + ;; + -h | --h*) + cat <<\EOF +Usage: depcomp [--help] [--version] PROGRAM [ARGS] + +Run PROGRAMS ARGS to compile a file, generating dependencies +as side-effects. + +Environment variables: + depmode Dependency tracking mode. + source Source file read by `PROGRAMS ARGS'. + object Object file output by `PROGRAMS ARGS'. + DEPDIR directory where to store dependencies. + depfile Dependency file to output. + tmpdepfile Temporary file to use when outputing dependencies. + libtool Whether libtool is used (yes/no). + +Report bugs to . +EOF + exit $? + ;; + -v | --v*) + echo "depcomp $scriptversion" + exit $? + ;; +esac + +if test -z "$depmode" || test -z "$source" || test -z "$object"; then + echo "depcomp: Variables source, object and depmode must be set" 1>&2 + exit 1 +fi + +# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. +depfile=${depfile-`echo "$object" | + sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} +tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} + +rm -f "$tmpdepfile" + +# Some modes work just like other modes, but use different flags. We +# parameterize here, but still list the modes in the big case below, +# to make depend.m4 easier to write. Note that we *cannot* use a case +# here, because this file can only contain one case statement. +if test "$depmode" = hp; then + # HP compiler uses -M and no extra arg. + gccflag=-M + depmode=gcc +fi + +if test "$depmode" = dashXmstdout; then + # This is just like dashmstdout with a different argument. + dashmflag=-xM + depmode=dashmstdout +fi + +case "$depmode" in +gcc3) +## gcc 3 implements dependency tracking that does exactly what +## we want. Yay! Note: for some reason libtool 1.4 doesn't like +## it if -MD -MP comes after the -MF stuff. Hmm. + "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + mv "$tmpdepfile" "$depfile" + ;; + +gcc) +## There are various ways to get dependency output from gcc. Here's +## why we pick this rather obscure method: +## - Don't want to use -MD because we'd like the dependencies to end +## up in a subdir. Having to rename by hand is ugly. +## (We might end up doing this anyway to support other compilers.) +## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like +## -MM, not -M (despite what the docs say). +## - Using -M directly means running the compiler twice (even worse +## than renaming). + if test -z "$gccflag"; then + gccflag=-MD, + fi + "$@" -Wp,"$gccflag$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + echo "$object : \\" > "$depfile" + alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz +## The second -e expression handles DOS-style file names with drive letters. + sed -e 's/^[^:]*: / /' \ + -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" +## This next piece of magic avoids the `deleted header file' problem. +## The problem is that when a header file which appears in a .P file +## is deleted, the dependency causes make to die (because there is +## typically no way to rebuild the header). We avoid this by adding +## dummy dependencies for each header file. Too bad gcc doesn't do +## this for us directly. + tr ' ' ' +' < "$tmpdepfile" | +## Some versions of gcc put a space before the `:'. On the theory +## that the space means something, we add a space to the output as +## well. +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +hp) + # This case exists only to let depend.m4 do its work. It works by + # looking at the text of this script. This case will never be run, + # since it is checked for above. + exit 1 + ;; + +sgi) + if test "$libtool" = yes; then + "$@" "-Wp,-MDupdate,$tmpdepfile" + else + "$@" -MDupdate "$tmpdepfile" + fi + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files + echo "$object : \\" > "$depfile" + + # Clip off the initial element (the dependent). Don't try to be + # clever and replace this with sed code, as IRIX sed won't handle + # lines with more than a fixed number of characters (4096 in + # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; + # the IRIX cc adds comments like `#:fec' to the end of the + # dependency line. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \ + tr ' +' ' ' >> $depfile + echo >> $depfile + + # The second pass generates a dummy entry for each header file. + tr ' ' ' +' < "$tmpdepfile" \ + | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ + >> $depfile + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +aix) + # The C for AIX Compiler uses -M and outputs the dependencies + # in a .u file. In older versions, this file always lives in the + # current directory. Also, the AIX compiler puts `$object:' at the + # start of each line; $object doesn't have directory information. + # Version 6 uses the directory in both cases. + stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'` + tmpdepfile="$stripped.u" + if test "$libtool" = yes; then + "$@" -Wc,-M + else + "$@" -M + fi + stat=$? + + if test -f "$tmpdepfile"; then : + else + stripped=`echo "$stripped" | sed 's,^.*/,,'` + tmpdepfile="$stripped.u" + fi + + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + + if test -f "$tmpdepfile"; then + outname="$stripped.o" + # Each line is of the form `foo.o: dependent.h'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile" + sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile" + else + # The sourcefile does not contain any dependencies, so just + # store a dummy comment line, to avoid errors with the Makefile + # "include basename.Plo" scheme. + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +icc) + # Intel's C compiler understands `-MD -MF file'. However on + # icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c + # ICC 7.0 will fill foo.d with something like + # foo.o: sub/foo.c + # foo.o: sub/foo.h + # which is wrong. We want: + # sub/foo.o: sub/foo.c + # sub/foo.o: sub/foo.h + # sub/foo.c: + # sub/foo.h: + # ICC 7.1 will output + # foo.o: sub/foo.c sub/foo.h + # and will wrap long lines using \ : + # foo.o: sub/foo.c ... \ + # sub/foo.h ... \ + # ... + + "$@" -MD -MF "$tmpdepfile" + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + # Each line is of the form `foo.o: dependent.h', + # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. + # Do two passes, one to just change these to + # `$object: dependent.h' and one to simply `dependent.h:'. + sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" + # Some versions of the HPUX 10.20 sed can't process this invocation + # correctly. Breaking it into two sed invocations is a workaround. + sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" | + sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +ia64hp) + # The "hp" stanza above does not work with HP's ia64 compilers, + # which have integrated preprocessors. The correct option to use + # with these is +Maked; it writes dependencies to a file named + # 'foo.d', which lands next to the object file, wherever that + # happens to be. + tmpdepfile=`echo "$object" | sed -e 's/\.o$/.d/'` + "$@" +Maked + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile" + exit $stat + fi + rm -f "$depfile" + + # The object file name is correct already. + cat "$tmpdepfile" > "$depfile" + # Add `dependent.h:' lines. + sed -ne '2,${; s/^ //; s/ \\*$//; s/$/:/; p; }' "$tmpdepfile" >> "$depfile" + rm -f "$tmpdepfile" + ;; + +tru64) + # The Tru64 compiler uses -MD to generate dependencies as a side + # effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'. + # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put + # dependencies in `foo.d' instead, so we check for that too. + # Subdirectories are respected. + dir=`echo "$object" | sed -e 's|/[^/]*$|/|'` + test "x$dir" = "x$object" && dir= + base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'` + + if test "$libtool" = yes; then + # With Tru64 cc, shared objects can also be used to make a + # static library. This mecanism is used in libtool 1.4 series to + # handle both shared and static libraries in a single compilation. + # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d. + # + # With libtool 1.5 this exception was removed, and libtool now + # generates 2 separate objects for the 2 libraries. These two + # compilations output dependencies in in $dir.libs/$base.o.d and + # in $dir$base.o.d. We have to check for both files, because + # one of the two compilations can be disabled. We should prefer + # $dir$base.o.d over $dir.libs/$base.o.d because the latter is + # automatically cleaned when .libs/ is deleted, while ignoring + # the former would cause a distcleancheck panic. + tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4 + tmpdepfile2=$dir$base.o.d # libtool 1.5 + tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5 + tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504 + "$@" -Wc,-MD + else + tmpdepfile1=$dir$base.o.d + tmpdepfile2=$dir$base.d + tmpdepfile3=$dir$base.d + tmpdepfile4=$dir$base.d + "$@" -MD + fi + + stat=$? + if test $stat -eq 0; then : + else + rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + exit $stat + fi + + for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4" + do + test -f "$tmpdepfile" && break + done + if test -f "$tmpdepfile"; then + sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile" + # That's a tab and a space in the []. + sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile" + else + echo "#dummy" > "$depfile" + fi + rm -f "$tmpdepfile" + ;; + +#nosideeffect) + # This comment above is used by automake to tell side-effect + # dependency tracking mechanisms from slower ones. + +dashmstdout) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + test -z "$dashmflag" && dashmflag=-M + # Require at least two characters before searching for `:' + # in the target name. This is to cope with DOS-style filenames: + # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise. + "$@" $dashmflag | + sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + tr ' ' ' +' < "$tmpdepfile" | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +dashXmstdout) + # This case only exists to satisfy depend.m4. It is never actually + # run, as this mode is specially recognized in the preamble. + exit 1 + ;; + +makedepend) + "$@" || exit $? + # Remove any Libtool call + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + # X makedepend + shift + cleared=no + for arg in "$@"; do + case $cleared in + no) + set ""; shift + cleared=yes ;; + esac + case "$arg" in + -D*|-I*) + set fnord "$@" "$arg"; shift ;; + # Strip any option that makedepend may not understand. Remove + # the object too, otherwise makedepend will parse it as a source file. + -*|$object) + ;; + *) + set fnord "$@" "$arg"; shift ;; + esac + done + obj_suffix="`echo $object | sed 's/^.*\././'`" + touch "$tmpdepfile" + ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" + rm -f "$depfile" + cat < "$tmpdepfile" > "$depfile" + sed '1,2d' "$tmpdepfile" | tr ' ' ' +' | \ +## Some versions of the HPUX 10.20 sed can't process this invocation +## correctly. Breaking it into two sed invocations is a workaround. + sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" "$tmpdepfile".bak + ;; + +cpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout. + "$@" || exit $? + + # Remove the call to Libtool. + if test "$libtool" = yes; then + while test $1 != '--mode=compile'; do + shift + done + shift + fi + + # Remove `-o $object'. + IFS=" " + for arg + do + case $arg in + -o) + shift + ;; + $object) + shift + ;; + *) + set fnord "$@" "$arg" + shift # fnord + shift # $arg + ;; + esac + done + + "$@" -E | + sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ + -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' | + sed '$ s: \\$::' > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + cat < "$tmpdepfile" >> "$depfile" + sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +msvisualcpp) + # Important note: in order to support this mode, a compiler *must* + # always write the preprocessed file to stdout, regardless of -o, + # because we must use -o when running libtool. + "$@" || exit $? + IFS=" " + for arg + do + case "$arg" in + "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") + set fnord "$@" + shift + shift + ;; + *) + set fnord "$@" "$arg" + shift + shift + ;; + esac + done + "$@" -E | + sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile" + rm -f "$depfile" + echo "$object : \\" > "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile" + echo " " >> "$depfile" + . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile" + rm -f "$tmpdepfile" + ;; + +none) + exec "$@" + ;; + +*) + echo "Unknown depmode $depmode" 1>&2 + exit 1 + ;; +esac + +exit 0 + +# Local Variables: +# mode: shell-script +# sh-indentation: 2 +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/install-sh b/install-sh new file mode 100755 index 0000000..4d4a951 --- /dev/null +++ b/install-sh @@ -0,0 +1,323 @@ +#!/bin/sh +# install - install a program, script, or datafile + +scriptversion=2005-05-14.22 + +# This originates from X11R5 (mit/util/scripts/install.sh), which was +# later released in X11R6 (xc/config/util/install.sh) with the +# following copyright and license. +# +# Copyright (C) 1994 X Consortium +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN +# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- +# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# +# Except as contained in this notice, the name of the X Consortium shall not +# be used in advertising or otherwise to promote the sale, use or other deal- +# ings in this Software without prior written authorization from the X Consor- +# tium. +# +# +# FSF changes to this file are in the public domain. +# +# Calling this script install-sh is preferred over install.sh, to prevent +# `make' implicit rules from creating a file called install from it +# when there is no Makefile. +# +# This script is compatible with the BSD install script, but was written +# from scratch. It can only install one file at a time, a restriction +# shared with many OS's install programs. + +# set DOITPROG to echo to test this script + +# Don't use :- since 4.3BSD and earlier shells don't like it. +doit="${DOITPROG-}" + +# put in absolute paths if you don't have them in your path; or use env. vars. + +mvprog="${MVPROG-mv}" +cpprog="${CPPROG-cp}" +chmodprog="${CHMODPROG-chmod}" +chownprog="${CHOWNPROG-chown}" +chgrpprog="${CHGRPPROG-chgrp}" +stripprog="${STRIPPROG-strip}" +rmprog="${RMPROG-rm}" +mkdirprog="${MKDIRPROG-mkdir}" + +chmodcmd="$chmodprog 0755" +chowncmd= +chgrpcmd= +stripcmd= +rmcmd="$rmprog -f" +mvcmd="$mvprog" +src= +dst= +dir_arg= +dstarg= +no_target_directory= + +usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE + or: $0 [OPTION]... SRCFILES... DIRECTORY + or: $0 [OPTION]... -t DIRECTORY SRCFILES... + or: $0 [OPTION]... -d DIRECTORIES... + +In the 1st form, copy SRCFILE to DSTFILE. +In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. +In the 4th, create DIRECTORIES. + +Options: +-c (ignored) +-d create directories instead of installing files. +-g GROUP $chgrpprog installed files to GROUP. +-m MODE $chmodprog installed files to MODE. +-o USER $chownprog installed files to USER. +-s $stripprog installed files. +-t DIRECTORY install into DIRECTORY. +-T report an error if DSTFILE is a directory. +--help display this help and exit. +--version display version info and exit. + +Environment variables override the default commands: + CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG +" + +while test -n "$1"; do + case $1 in + -c) shift + continue;; + + -d) dir_arg=true + shift + continue;; + + -g) chgrpcmd="$chgrpprog $2" + shift + shift + continue;; + + --help) echo "$usage"; exit $?;; + + -m) chmodcmd="$chmodprog $2" + shift + shift + continue;; + + -o) chowncmd="$chownprog $2" + shift + shift + continue;; + + -s) stripcmd=$stripprog + shift + continue;; + + -t) dstarg=$2 + shift + shift + continue;; + + -T) no_target_directory=true + shift + continue;; + + --version) echo "$0 $scriptversion"; exit $?;; + + *) # When -d is used, all remaining arguments are directories to create. + # When -t is used, the destination is already specified. + test -n "$dir_arg$dstarg" && break + # Otherwise, the last argument is the destination. Remove it from $@. + for arg + do + if test -n "$dstarg"; then + # $@ is not empty: it contains at least $arg. + set fnord "$@" "$dstarg" + shift # fnord + fi + shift # arg + dstarg=$arg + done + break;; + esac +done + +if test -z "$1"; then + if test -z "$dir_arg"; then + echo "$0: no input file specified." >&2 + exit 1 + fi + # It's OK to call `install-sh -d' without argument. + # This can happen when creating conditional directories. + exit 0 +fi + +for src +do + # Protect names starting with `-'. + case $src in + -*) src=./$src ;; + esac + + if test -n "$dir_arg"; then + dst=$src + src= + + if test -d "$dst"; then + mkdircmd=: + chmodcmd= + else + mkdircmd=$mkdirprog + fi + else + # Waiting for this to be detected by the "$cpprog $src $dsttmp" command + # might cause directories to be created, which would be especially bad + # if $src (and thus $dsttmp) contains '*'. + if test ! -f "$src" && test ! -d "$src"; then + echo "$0: $src does not exist." >&2 + exit 1 + fi + + if test -z "$dstarg"; then + echo "$0: no destination specified." >&2 + exit 1 + fi + + dst=$dstarg + # Protect names starting with `-'. + case $dst in + -*) dst=./$dst ;; + esac + + # If destination is a directory, append the input filename; won't work + # if double slashes aren't ignored. + if test -d "$dst"; then + if test -n "$no_target_directory"; then + echo "$0: $dstarg: Is a directory" >&2 + exit 1 + fi + dst=$dst/`basename "$src"` + fi + fi + + # This sed command emulates the dirname command. + dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'` + + # Make sure that the destination directory exists. + + # Skip lots of stat calls in the usual case. + if test ! -d "$dstdir"; then + defaultIFS=' + ' + IFS="${IFS-$defaultIFS}" + + oIFS=$IFS + # Some sh's can't handle IFS=/ for some reason. + IFS='%' + set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'` + shift + IFS=$oIFS + + pathcomp= + + while test $# -ne 0 ; do + pathcomp=$pathcomp$1 + shift + if test ! -d "$pathcomp"; then + $mkdirprog "$pathcomp" + # mkdir can fail with a `File exist' error in case several + # install-sh are creating the directory concurrently. This + # is OK. + test -d "$pathcomp" || exit + fi + pathcomp=$pathcomp/ + done + fi + + if test -n "$dir_arg"; then + $doit $mkdircmd "$dst" \ + && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; } + + else + dstfile=`basename "$dst"` + + # Make a couple of temp file names in the proper directory. + dsttmp=$dstdir/_inst.$$_ + rmtmp=$dstdir/_rm.$$_ + + # Trap to clean up those temp files at exit. + trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 + trap '(exit $?); exit' 1 2 13 15 + + # Copy the file name to the temp name. + $doit $cpprog "$src" "$dsttmp" && + + # and set any options; do chmod last to preserve setuid bits. + # + # If any of these fail, we abort the whole thing. If we want to + # ignore errors from any of these, just make sure not to ignore + # errors from the above "$doit $cpprog $src $dsttmp" command. + # + { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \ + && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \ + && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \ + && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } && + + # Now rename the file to the real destination. + { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \ + || { + # The rename failed, perhaps because mv can't rename something else + # to itself, or perhaps because mv is so ancient that it does not + # support -f. + + # Now remove or move aside any old file at destination location. + # We try this two ways since rm can't unlink itself on some + # systems and the destination file might be busy for other + # reasons. In this case, the final cleanup might fail but the new + # file should still install successfully. + { + if test -f "$dstdir/$dstfile"; then + $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \ + || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \ + || { + echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2 + (exit 1); exit 1 + } + else + : + fi + } && + + # Now rename the file to the real destination. + $doit $mvcmd "$dsttmp" "$dstdir/$dstfile" + } + } + fi || { (exit 1); exit 1; } +done + +# The final little trick to "correctly" pass the exit status to the exit trap. +{ + (exit 0); exit 0 +} + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: diff --git a/missing b/missing new file mode 100755 index 0000000..894e786 --- /dev/null +++ b/missing @@ -0,0 +1,360 @@ +#! /bin/sh +# Common stub for a few missing GNU programs while installing. + +scriptversion=2005-06-08.21 + +# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005 +# Free Software Foundation, Inc. +# Originally by Fran,cois Pinard , 1996. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +# 02110-1301, USA. + +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +if test $# -eq 0; then + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 +fi + +run=: + +# In the cases where this matters, `missing' is being run in the +# srcdir already. +if test -f configure.ac; then + configure_ac=configure.ac +else + configure_ac=configure.in +fi + +msg="missing on your system" + +case "$1" in +--run) + # Try to run requested program, and just exit if it succeeds. + run= + shift + "$@" && exit 0 + # Exit code 63 means version mismatch. This often happens + # when the user try to use an ancient version of a tool on + # a file that requires a minimum version. In this case we + # we should proceed has if the program had been absent, or + # if --run hadn't been passed. + if test $? = 63; then + run=: + msg="probably too old" + fi + ;; + + -h|--h|--he|--hel|--help) + echo "\ +$0 [OPTION]... PROGRAM [ARGUMENT]... + +Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an +error status if there is no known handling for PROGRAM. + +Options: + -h, --help display this help and exit + -v, --version output version information and exit + --run try to run the given command, and emulate it if it fails + +Supported PROGRAM values: + aclocal touch file \`aclocal.m4' + autoconf touch file \`configure' + autoheader touch file \`config.h.in' + automake touch all \`Makefile.in' files + bison create \`y.tab.[ch]', if possible, from existing .[ch] + flex create \`lex.yy.c', if possible, from existing .c + help2man touch the output file + lex create \`lex.yy.c', if possible, from existing .c + makeinfo touch the output file + tar try tar, gnutar, gtar, then tar without non-portable flags + yacc create \`y.tab.[ch]', if possible, from existing .[ch] + +Send bug reports to ." + exit $? + ;; + + -v|--v|--ve|--ver|--vers|--versi|--versio|--version) + echo "missing $scriptversion (GNU Automake)" + exit $? + ;; + + -*) + echo 1>&2 "$0: Unknown \`$1' option" + echo 1>&2 "Try \`$0 --help' for more information" + exit 1 + ;; + +esac + +# Now exit if we have it, but it failed. Also exit now if we +# don't have it and --version was passed (most likely to detect +# the program). +case "$1" in + lex|yacc) + # Not GNU programs, they don't have --version. + ;; + + tar) + if test -n "$run"; then + echo 1>&2 "ERROR: \`tar' requires --run" + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + exit 1 + fi + ;; + + *) + if test -z "$run" && ($1 --version) > /dev/null 2>&1; then + # We have it, but it failed. + exit 1 + elif test "x$2" = "x--version" || test "x$2" = "x--help"; then + # Could not run --version or --help. This is probably someone + # running `$TOOL --version' or `$TOOL --help' to check whether + # $TOOL exists and not knowing $TOOL uses missing. + exit 1 + fi + ;; +esac + +# If it does not exist, or fails to run (possibly an outdated version), +# try to emulate it. +case "$1" in + aclocal*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acinclude.m4' or \`${configure_ac}'. You might want + to install the \`Automake' and \`Perl' packages. Grab them from + any GNU archive site." + touch aclocal.m4 + ;; + + autoconf) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`${configure_ac}'. You might want to install the + \`Autoconf' and \`GNU m4' packages. Grab them from any GNU + archive site." + touch configure + ;; + + autoheader) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`acconfig.h' or \`${configure_ac}'. You might want + to install the \`Autoconf' and \`GNU m4' packages. Grab them + from any GNU archive site." + files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}` + test -z "$files" && files="config.h" + touch_files= + for f in $files; do + case "$f" in + *:*) touch_files="$touch_files "`echo "$f" | + sed -e 's/^[^:]*://' -e 's/:.*//'`;; + *) touch_files="$touch_files $f.in";; + esac + done + touch $touch_files + ;; + + automake*) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'. + You might want to install the \`Automake' and \`Perl' packages. + Grab them from any GNU archive site." + find . -type f -name Makefile.am -print | + sed 's/\.am$/.in/' | + while read f; do touch "$f"; done + ;; + + autom4te) + echo 1>&2 "\ +WARNING: \`$1' is needed, but is $msg. + You might have modified some files without having the + proper tools for further handling them. + You can get \`$1' as part of \`Autoconf' from any GNU + archive site." + + file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'` + test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'` + if test -f "$file"; then + touch $file + else + test -z "$file" || exec >$file + echo "#! /bin/sh" + echo "# Created by GNU Automake missing as a replacement of" + echo "# $ $@" + echo "exit 0" + chmod +x $file + exit 1 + fi + ;; + + bison|yacc) + echo 1>&2 "\ +WARNING: \`$1' $msg. You should only need it if + you modified a \`.y' file. You may need the \`Bison' package + in order for those modifications to take effect. You can get + \`Bison' from any GNU archive site." + rm -f y.tab.c y.tab.h + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.y) + SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.c + fi + SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" y.tab.h + fi + ;; + esac + fi + if [ ! -f y.tab.h ]; then + echo >y.tab.h + fi + if [ ! -f y.tab.c ]; then + echo 'main() { return 0; }' >y.tab.c + fi + ;; + + lex|flex) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.l' file. You may need the \`Flex' package + in order for those modifications to take effect. You can get + \`Flex' from any GNU archive site." + rm -f lex.yy.c + if [ $# -ne 1 ]; then + eval LASTARG="\${$#}" + case "$LASTARG" in + *.l) + SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'` + if [ -f "$SRCFILE" ]; then + cp "$SRCFILE" lex.yy.c + fi + ;; + esac + fi + if [ ! -f lex.yy.c ]; then + echo 'main() { return 0; }' >lex.yy.c + fi + ;; + + help2man) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a dependency of a manual page. You may need the + \`Help2man' package in order for those modifications to take + effect. You can get \`Help2man' from any GNU archive site." + + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'` + fi + if [ -f "$file" ]; then + touch $file + else + test -z "$file" || exec >$file + echo ".ab help2man is required to generate this page" + exit 1 + fi + ;; + + makeinfo) + echo 1>&2 "\ +WARNING: \`$1' is $msg. You should only need it if + you modified a \`.texi' or \`.texinfo' file, or any other file + indirectly affecting the aspect of the manual. The spurious + call might also be the consequence of using a buggy \`make' (AIX, + DU, IRIX). You might want to install the \`Texinfo' package or + the \`GNU make' package. Grab either from any GNU archive site." + # The file to touch is that specified with -o ... + file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'` + if test -z "$file"; then + # ... or it is the one specified with @setfilename ... + infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'` + file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile` + # ... or it is derived from the source name (dir/f.texi becomes f.info) + test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info + fi + # If the file does not exist, the user really needs makeinfo; + # let's fail without touching anything. + test -f $file || exit 1 + touch $file + ;; + + tar) + shift + + # We have already tried tar in the generic part. + # Look for gnutar/gtar before invocation to avoid ugly error + # messages. + if (gnutar --version > /dev/null 2>&1); then + gnutar "$@" && exit 0 + fi + if (gtar --version > /dev/null 2>&1); then + gtar "$@" && exit 0 + fi + firstarg="$1" + if shift; then + case "$firstarg" in + *o*) + firstarg=`echo "$firstarg" | sed s/o//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + case "$firstarg" in + *h*) + firstarg=`echo "$firstarg" | sed s/h//` + tar "$firstarg" "$@" && exit 0 + ;; + esac + fi + + echo 1>&2 "\ +WARNING: I can't seem to be able to run \`tar' with the given arguments. + You may want to install GNU tar or Free paxutils, or check the + command line arguments." + exit 1 + ;; + + *) + echo 1>&2 "\ +WARNING: \`$1' is needed, and is $msg. + You might have modified some files without having the + proper tools for further handling them. Check the \`README' file, + it often tells you about the needed prerequisites for installing + this package. You may also peek at any GNU archive site, in case + some other package would contain this missing \`$1' program." + exit 1 + ;; +esac + +exit 0 + +# Local variables: +# eval: (add-hook 'write-file-hooks 'time-stamp) +# time-stamp-start: "scriptversion=" +# time-stamp-format: "%:y-%02m-%02d.%02H" +# time-stamp-end: "$" +# End: From 3f71a9b364c8b501bc5cc2a1c27eebe5b76f2221 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 22 Feb 2015 20:27:05 +0000 Subject: [PATCH 02/71] Amend documentation to make it explicit that debugger d and bl work on watchpoints as well as breakpoints. --- README | 6 +++--- command.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README b/README index 4bb6672..5610146 100644 --- a/README +++ b/README @@ -57,11 +57,11 @@ TODO : Would anyone be interested in a CoCo machine type? ----------------------------------------------------------------- Faults -====== + ----------------------------------------------------------------- Debugging -========= + The simulator supports interactive debugging similar to that provided by 'gdb'. @@ -70,7 +70,7 @@ b Set a breakpoint at the given address. bl - List all breakpoints. + List all breakpoints/watchpoints. c Continue running. diff --git a/command.c b/command.c index 03d6deb..2955f87 100644 --- a/command.c +++ b/command.c @@ -1141,9 +1141,9 @@ struct command_name { "b", "break", cmd_break, "Set a breakpoint" }, { "bl", "blist", cmd_break_list, - "List all breakpoints" }, + "List all breakpoints/watchpoints" }, { "d", "delete", cmd_delete, - "Delete a breakpoint" }, + "Delete a breakpoint/watchpoint" }, { "s", "step", cmd_step, "Step one instruction" }, { "n", "next", cmd_next, From 985f9c9a45dc8321cd4e2ab4fa5187243fd2a9df Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 22 Feb 2015 21:15:02 +0000 Subject: [PATCH 03/71] include header files to remove compile warnings for malloc, memset. --- disk.c | 2 ++ imux.c | 1 + serial.c | 1 + timer.c | 1 + 4 files changed, 5 insertions(+) diff --git a/disk.c b/disk.c index a9a9203..619c6fb 100644 --- a/disk.c +++ b/disk.c @@ -19,6 +19,8 @@ */ #include +#include +#include #include "machine.h" #include "eon.h" diff --git a/imux.c b/imux.c index 3b52584..1d5ba37 100644 --- a/imux.c +++ b/imux.c @@ -20,6 +20,7 @@ /* The interrupt multiplexer */ +#include #include "machine.h" #include "eon.h" diff --git a/serial.c b/serial.c index 80fa765..5d7a8af 100644 --- a/serial.c +++ b/serial.c @@ -23,6 +23,7 @@ #include #include #include +#include #include "machine.h" /* Emulate a serial port. Basically this driver can be used for any byte-at-a-time diff --git a/timer.c b/timer.c index 6d618a3..bc762b6 100644 --- a/timer.c +++ b/timer.c @@ -19,6 +19,7 @@ */ #include +#include #include "machine.h" /* A hardware timer counts CPU cycles and can generate interrupts periodically. */ From bfea51060d694ed3ba69ca888831d8e6c7a5f3c1 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 22 Feb 2015 21:20:24 +0000 Subject: [PATCH 04/71] Remove noise from git status output --- .gitignore | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9ddf77d --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Result of ./configure +.deps +config.h +config.log +config.status +m6809-run +stamp-h1 +Makefile +aclocal.m4 +autom4te.cache + +# Result of make +*.o + +# Result of emacs edits +*~ From 0fd30b9ea27fbec76df4ff1da9758a60a4ac2920 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 22 Feb 2015 21:28:52 +0000 Subject: [PATCH 05/71] missing braces on if() meant that argument processing was broken. Fixed some indent issues. --- main.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/main.c b/main.c index 01e06e2..3585678 100644 --- a/main.c +++ b/main.c @@ -268,7 +268,9 @@ process_option (struct option *opt, const char *arg) else { if (arg) + { //printf (" Takes no argument but one given, ignored.\n"); + } if (opt->int_value) { @@ -365,7 +367,7 @@ main (int argc, char *argv[]) int argn = 1; unsigned int loops = 0; - gettimeofday (&time_started, NULL); + gettimeofday (&time_started, NULL); exename = argv[0]; /* TODO - enable different options by default @@ -402,14 +404,18 @@ main (int argc, char *argv[]) /* Enable debugging if no executable given yet. */ if (!prog_name) + { debug_enabled = 1; + } else + { /* OK, ready to run. Reset the CPU first. */ cpu_reset (); + } monitor_init (); command_init (); - keybuffering (0); + keybuffering (0); /* Now, iterate through the instructions. * If no IRQs or FIRQs are enabled, we can just call cpu_execute() From 07a5d8af36849fe0485be7c4af4de2277eb2404b Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sat, 28 Feb 2015 14:04:38 +0000 Subject: [PATCH 06/71] Fix compilation warnings. --- disk.c | 8 +++++--- serial.c | 11 ++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/disk.c b/disk.c index 619c6fb..88a4947 100644 --- a/disk.c +++ b/disk.c @@ -21,7 +21,8 @@ #include #include #include -#include "machine.h" +#include +#include "6809.h" #include "eon.h" /* The disk drive is emulated as follows: @@ -74,7 +75,7 @@ U8 disk_read (struct hw_device *dev, unsigned long addr) void disk_write (struct hw_device *dev, unsigned long addr, U8 val) { struct disk_priv *disk = (struct disk_priv *)dev->priv; - + int retvar; switch (addr) { case DSK_ADDR: @@ -92,7 +93,8 @@ void disk_write (struct hw_device *dev, unsigned long addr, U8 val) case DSK_CTRL: if (val & DSK_READ) { - fread (disk->ram, SECTOR_SIZE, 1, disk->fp); + retvar = fread (disk->ram, SECTOR_SIZE, 1, disk->fp); + assert(retvar != -1); } else if (val & DSK_WRITE) { diff --git a/serial.c b/serial.c index 5d7a8af..3cdec4b 100644 --- a/serial.c +++ b/serial.c @@ -22,8 +22,9 @@ #include #include #include -#include #include +#include +#include #include "machine.h" /* Emulate a serial port. Basically this driver can be used for any byte-at-a-time @@ -71,6 +72,7 @@ void serial_update (struct serial_port *port) U8 serial_read (struct hw_device *dev, unsigned long addr) { struct serial_port *port = (struct serial_port *)dev->priv; + int retval; serial_update (port); switch (addr) { @@ -79,7 +81,8 @@ U8 serial_read (struct hw_device *dev, unsigned long addr) U8 val; if (!(port->status & SER_STAT_READOK)) return 0xFF; - read (port->fin, &val, 1); + retval = read (port->fin, &val, 1); + assert(retval != -1); return val; } case SER_CTL_STATUS: @@ -90,12 +93,14 @@ U8 serial_read (struct hw_device *dev, unsigned long addr) void serial_write (struct hw_device *dev, unsigned long addr, U8 val) { struct serial_port *port = (struct serial_port *)dev->priv; + int retval; switch (addr) { case SER_DATA: { U8 v = val; - write (port->fout, &v, 1); + retval = write (port->fout, &v, 1); + assert(retval != -1); break; } case SER_CTL_STATUS: From 8315b9911dfdefd9247887dd9c7b26413062143e Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sat, 28 Feb 2015 14:05:09 +0000 Subject: [PATCH 07/71] Allow "step" command to take argument: step for N instructions. --- README | 4 ++-- command.c | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README b/README index 5610146..6aca158 100644 --- a/README +++ b/README @@ -109,8 +109,8 @@ re runfor Continue but break after a certain period of (simulated) time. -s - Step one CPU instruction. +s + Step for a certain number of CPU instructions (1 by default). set Sets the value of an internal variable or target memory. diff --git a/command.c b/command.c index 2955f87..197b070 100644 --- a/command.c +++ b/command.c @@ -876,7 +876,12 @@ void cmd_break_list (void) void cmd_step (void) { - auto_break_insn_count = 1; + char *arg = getarg (); + if (arg) + auto_break_insn_count = atoi(arg); + else + auto_break_insn_count = 1; + exit_command_loop = 0; } @@ -1145,7 +1150,7 @@ struct command_name { "d", "delete", cmd_delete, "Delete a breakpoint/watchpoint" }, { "s", "step", cmd_step, - "Step one instruction" }, + "Step one (or more) instructions" }, { "n", "next", cmd_next, "Break at the next instruction" }, { "c", "continue", cmd_continue, From ef4d701904fe84e8e9dfe54f0fe79220e682c967 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sat, 28 Feb 2015 22:27:22 +0000 Subject: [PATCH 08/71] Add .name field to hw_class and set it up for all classes. Expand dump_machine to print machine name and device list. Change printing of map so that it only prints on interesting boundaries (basically, when anything changes). Add info command that calls dump_machine. Update documentation accordingly. Tweak serial.c to stop eon2 from core-dumping. --- README | 16 ++++++++++++++-- command.c | 9 +++++++-- disk.c | 1 + machine.c | 56 ++++++++++++++++++++++++++++++++++++++++++++----------- machine.h | 3 +++ mmu.c | 1 + serial.c | 3 ++- timer.c | 1 + wpc.c | 1 + 9 files changed, 75 insertions(+), 16 deletions(-) diff --git a/README b/README index 6aca158..aae2051 100644 --- a/README +++ b/README @@ -11,8 +11,18 @@ stuff. Then: > ./configure > make -There is one executable, m6809-run. You can install it (make install) or -simply reference it explicitly. +There is one executable, m6809-run. You can install it +("make install") or simply reference it explicitly. + +To see configure options: + +> ./configure --help + +Enable readline libraries if you have them installed; this will +allow you to use command-line recall and other shortcuts at the +debugger command-line: + +> ./configure --enable-readline ----------------------------------------------------------------- Input Files @@ -136,6 +146,8 @@ wa x Examine target memory at the address given. +info + Describe machine, devices and address mapping. ----------------------------------------------------------------- Original README text from Arto: diff --git a/command.c b/command.c index 197b070..47c8786 100644 --- a/command.c +++ b/command.c @@ -1,4 +1,3 @@ - #include "6809.h" #include "monitor.h" #include "machine.h" @@ -1126,6 +1125,11 @@ void cmd_restore (void) { } +void cmd_info (void) +{ + dump_machine(); +} + /****************** Parser ************************/ void cmd_help (void); @@ -1192,9 +1196,10 @@ struct command_name "Dump contents of memory to a file" }, { "restore", "res", cmd_restore, "Restore contents of memory from a file" }, + { "i", "info", cmd_info, + "Describe machine, devices and address mapping" }, #if 0 { "cl", "clear", cmd_clear }, - { "i", "info", cmd_info }, { "co", "condition", cmd_condition }, { "tr", "trace", cmd_trace }, { "di", "disable", cmd_disable }, diff --git a/disk.c b/disk.c index 88a4947..1a7828c 100644 --- a/disk.c +++ b/disk.c @@ -140,6 +140,7 @@ void disk_format (struct hw_device *dev) struct hw_class disk_class = { + .name = "disk", .readonly = 0, .reset = disk_reset, .read = disk_read, diff --git a/machine.c b/machine.c index bfaafcc..067c443 100644 --- a/machine.c +++ b/machine.c @@ -30,9 +30,6 @@ #define MISSING 0xff #define mmu_device (device_table[0]) -extern void eon_init (const char *); -extern void wpc_init (const char *); - struct machine *machine; unsigned int device_count = 0; @@ -282,24 +279,56 @@ to_absolute (unsigned long cpuaddr) return absolute_from_reladdr (map->devid, phy_addr); } - +// Describe machine, devices and mapping. void dump_machine (void) { + unsigned int devno; unsigned int mapno; + unsigned int prev_devid = -1; + unsigned int prev_offset; + unsigned int prev_flags; + unsigned int dot_dot = 0; unsigned int n; + /* machine */ + printf("Machine: %s\n", machine->name); + + /* devices */ + for (devno = 0; devno < device_count; devno++) + { + printf("Device %2d: %s\n",devno, device_table[devno]->class_ptr->name); + } + + /* Mapping */ for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++) { struct bus_map *map = &busmaps[mapno]; - printf ("Map %d addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n", - mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset, - 0 /* device_table[map->devid]->size */, map->flags); - + if ((map->devid == prev_devid) && (map->offset == prev_offset) + && (map->flags == prev_flags)) + { + /* nothing interesting to report */ + if (! dot_dot) + { + printf("..\n"); + dot_dot = 1; + } + } + else + { + dot_dot = 0; + printf ("Map %3d: addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n", + mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset, + 0 /* device_table[map->devid]->size */, map->flags); #if 0 - for (n = 0; n < BUS_MAP_SIZE; n++) - printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n)); - printf ("\n"); + for (n = 0; n < BUS_MAP_SIZE; n++) + printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n)); + printf ("\n"); #endif + } + /* ready for next time */ + prev_devid = map->devid; + prev_offset = map->offset + BUS_MAP_SIZE; + prev_flags = map->flags; } } @@ -321,6 +350,7 @@ void null_write (struct hw_device *dev, unsigned long addr, U8 val) struct hw_class null_class = { + .name = "null-device", .readonly = 0, .reset = null_reset, .read = null_read, @@ -354,6 +384,7 @@ void ram_write (struct hw_device *dev, unsigned long addr, U8 val) struct hw_class ram_class = { + .name = "RAM", .readonly = 0, .reset = ram_reset, .read = ram_read, @@ -370,6 +401,7 @@ struct hw_device *ram_create (unsigned long size) struct hw_class rom_class = { + .name = "ROM", .readonly = 1, .reset = null_reset, .read = ram_read, @@ -440,6 +472,7 @@ void console_write (struct hw_device *dev, unsigned long addr, U8 val) struct hw_class console_class = { + .name = "console", .readonly = 0, .reset = null_reset, .read = console_read, @@ -523,6 +556,7 @@ void mmu_reset_complete (struct hw_device *dev) struct hw_class mmu_class = { + .name = "mmu", .readonly = 0, .reset = mmu_reset, .read = mmu_read, diff --git a/machine.h b/machine.h index 89b9358..123ad66 100644 --- a/machine.h +++ b/machine.h @@ -88,6 +88,9 @@ a single "ROM" class and multiple ROM device objects. */ struct hw_class { + /* Descriptive */ + char *name; + /* Nonzero if the device is readonly */ int readonly; diff --git a/mmu.c b/mmu.c index ceed65e..973ff65 100644 --- a/mmu.c +++ b/mmu.c @@ -94,6 +94,7 @@ void small_mmu_reset (struct hw_device *dev) struct hw_class small_mmu_class = { + .name = "small_mmu", .readonly = 0, .reset = small_mmu_reset, .read = small_mmu_read, diff --git a/serial.c b/serial.c index 3cdec4b..ea0d999 100644 --- a/serial.c +++ b/serial.c @@ -118,6 +118,7 @@ void serial_reset (struct hw_device *dev) struct hw_class serial_class = { + .name = "serial", .readonly = 0, .reset = serial_reset, .read = serial_read, @@ -138,7 +139,7 @@ struct hw_device *serial_create (void) struct hw_device *hostfile_create (const char *filename, int flags) { struct serial_port *port = malloc (sizeof (struct serial_port)); - port->fin = port->fout = open (filename, O_CREAT | flags); + port->fin = port->fout = open (filename, O_CREAT | flags, S_IRUSR | S_IWUSR); return device_attach (&serial_class, 4, port); } diff --git a/timer.c b/timer.c index bc762b6..865be73 100644 --- a/timer.c +++ b/timer.c @@ -144,6 +144,7 @@ void oscillator_reset (struct hw_device *dev) struct hw_class hwtimer_class = { + .name = "hwtimer", .readonly = 0, .reset = hwtimer_reset, .read = hwtimer_read, diff --git a/wpc.c b/wpc.c index 8abe817..02f81c2 100644 --- a/wpc.c +++ b/wpc.c @@ -627,6 +627,7 @@ void wpc_asic_reset (struct hw_device *dev) struct hw_class wpc_asic_class = { + .name = "wpc_asic", .reset = wpc_asic_reset, .read = wpc_asic_read, .write = wpc_asic_write, From 30a8f060e3acaf823dbc26aaeb5894788596cb3e Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 1 Mar 2015 14:36:30 +0000 Subject: [PATCH 09/71] Implement documented but empty "regs" command. --- 6809.c | 48 ++++++++++++++++++++++++++++++++++++------------ README | 1 + command.c | 2 +- 3 files changed, 38 insertions(+), 13 deletions(-) diff --git a/6809.c b/6809.c index 0c48f7b..d390fc5 100644 --- a/6809.c +++ b/6809.c @@ -2464,7 +2464,7 @@ cpu_execute (int cycles) indexed (); cpu_clk += 1; PC = ea; - check_pc (); + check_pc (); monitor_call (FC_TAIL_CALL); break; /* JMP indexed */ case 0x6f: @@ -2539,7 +2539,7 @@ cpu_execute (int cycles) extended (); cpu_clk -= 4; PC = ea; - check_pc (); + check_pc (); monitor_call (FC_TAIL_CALL); break; /* JMP extended */ case 0x7f: @@ -3126,13 +3126,13 @@ cpu_execute (int cycles) default: cpu_clk -= 2; - sim_error ("invalid opcode '%02X'\n", opcode); - PC = iPC; + sim_error ("invalid opcode '%02X'\n", opcode); + PC = iPC; break; } if (cc_changed) - cc_modified (); + cc_modified (); } while (cpu_clk > 0); @@ -3145,14 +3145,38 @@ cpu_execute (int cycles) void cpu_reset (void) { - X = Y = S = U = A = B = DP = 0; - H = N = OV = C = 0; - Z = 1; - EFI = F_FLAG | I_FLAG; + X = Y = S = U = A = B = DP = 0; + H = N = OV = C = 0; + Z = 1; + EFI = F_FLAG | I_FLAG; #ifdef H6309 - MD = E = F = V = 0; + MD = E = F = V = 0; #endif - change_pc (read16 (0xfffe)); - cpu_is_running (); + change_pc (read16 (0xfffe)); + cpu_is_running (); +} + +void +print_regs (void) +{ + char flags[8] = " "; + if (get_cc() & C_FLAG) flags[0] = 'C'; + if (get_cc() & V_FLAG) flags[1] = 'V'; + if (get_cc() & Z_FLAG) flags[2] = 'Z'; + if (get_cc() & N_FLAG) flags[3] = 'N'; + if (get_cc() & I_FLAG) flags[4] = 'I'; + if (get_cc() & H_FLAG) flags[5] = 'H'; + if (get_cc() & F_FLAG) flags[6] = 'F'; + if (get_cc() & E_FLAG) flags[7] = 'E'; + + printf (" X: 0x%04x [X]: 0x%04x Y: 0x%04x [Y]: 0x%04x ", + get_x(), read16(get_x()), get_y(), read16(get_y()) ); + printf ("PC: 0x%04x [PC]: 0x%04x\n", + get_pc(), read16(get_pc()) ); + printf (" U: 0x%04x [U]: 0x%04x S: 0x%04x [S]: 0x%04x ", + get_u(), read16(get_u()), get_s(), read16(get_s()) ); + printf ("DP: 0x%02x\n", get_dp() ); + printf (" A: 0x%02x B: 0x%02x [D]: 0x%04x CC: %s\n", + get_a(), get_b(), read16(get_d()), flags ); } diff --git a/README b/README index aae2051..400cc24 100644 --- a/README +++ b/README @@ -23,6 +23,7 @@ allow you to use command-line recall and other shortcuts at the debugger command-line: > ./configure --enable-readline +> make ----------------------------------------------------------------- Input Files diff --git a/command.c b/command.c index 47c8786..b0e608f 100644 --- a/command.c +++ b/command.c @@ -1019,9 +1019,9 @@ void cmd_source (void) fprintf (stderr, "can't open %s\n", arg); } - void cmd_regs (void) { + print_regs(); } void cmd_vars (void) From 90e77839fd9956acc7857a5df66cfffc28ece478 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 1 Mar 2015 19:55:59 +0000 Subject: [PATCH 10/71] Previously there was a .hex image file reader but no way to invoke it. Changed the image file reader to auto-detect the file type (currently supports hex and s19). Reworked the image file readers to cope with both Unix and DOS line endings and to do a bit more checking (which also reduced compilation warnings). --- 6809.h | 4 +- main.c | 39 ++++++--------- monitor.c | 145 ++++++++++++++++++++++++++++++++---------------------- 3 files changed, 101 insertions(+), 87 deletions(-) diff --git a/6809.h b/6809.h index 6d47908..d5fc634 100644 --- a/6809.h +++ b/6809.h @@ -135,9 +135,7 @@ extern void monitor_init (void); extern int monitor6809 (void); extern int dasm (char *, absolute_address_t); -extern int load_hex (const char *); -extern int load_s19 (const char *); -extern int load_bin (const char *,int); +extern int load_image (const char *); #define MAX_STRINGSPACE 32000 #define MAX_SYMBOL_HASH 1009 diff --git a/main.c b/main.c index 3585678..50dfe07 100644 --- a/main.c +++ b/main.c @@ -23,10 +23,6 @@ #include #include "6809.h" -enum -{ HEX, S19, BIN }; - - /* The total number of cycles that have executed */ unsigned long total = 0; @@ -63,7 +59,7 @@ int machine_persistent = 0; processor would run like. */ int machine_realtime = 0; -static int type = S19; +static int binary = 0; char *exename; @@ -170,7 +166,7 @@ struct option unsigned int can_negate : 1; unsigned int takes_arg : 1; int *int_value; - int default_value; + int default_value; /* value to set if option is present */ const char **string_value; int (*handler) (const char *arg); } option_table[] = { @@ -179,7 +175,7 @@ struct option { 'h', "help", NULL, NO_NEG, NO_ARG, NULL, 0, 0, do_help }, { 'b', "binary", "", - NO_NEG, NO_ARG, &type, BIN, NULL, NULL }, + NO_NEG, NO_ARG, &binary, 1, NULL, NULL }, { 'M', "mhz", "", NO_NEG, HAS_ARG }, { '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" }, { '-', "68b09", "Emulate the 68B09 variation (2Mhz)" }, @@ -377,25 +373,18 @@ main (int argc, char *argv[]) sym_init (); - switch (type) + if (binary) + { + machine_init (machine_name, prog_name); + } + else { - case HEX: - if (prog_name && load_hex (prog_name)) - usage (); - break; - - case S19: - /* The machine loader cannot deal with S-record files. - So initialize the machine first, passing it a NULL - filename, then load the S-record file afterwards. */ - machine_init (machine_name, NULL); - if (prog_name && load_s19 (prog_name)) - usage (); - break; - - default: - machine_init (machine_name, prog_name); - break; + /* The machine loader cannot deal with image files, + so initialize the machine first, passing it a NULL + filename, then load the image file afterwards. */ + machine_init (machine_name, NULL); + if (prog_name && load_image (prog_name)) + usage (); } /* Try to load a map file */ diff --git a/monitor.c b/monitor.c index 6e7aebb..8a52390 100644 --- a/monitor.c +++ b/monitor.c @@ -1168,22 +1168,48 @@ load_map_file (const char *name) } +/* Auto-detect image file type and load it. For this to work, + the machine must already be initialized. +*/ int -load_hex (const char *name) +load_image (const char *name) { + int count, addr, type; FILE *fp; - int count, addr, type, data, checksum; - int done = 1; - int line = 0; fp = file_open (NULL, name, "r"); if (fp == NULL) { - printf ("failed to open hex record file %s.\n", name); + printf ("failed to open image file %s.\n", name); return 1; } + if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) == 3) + { + rewind(fp); + return load_s19(fp); + } + else if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) == 3) + { + rewind(fp); + return load_hex(fp); + } + else + { + printf ("unrecognised format in image file %s.\n", name); + return 1; + } +} + + +int +load_hex (FILE *fp) +{ + int count, addr, type, data, checksum; + int done = 1; + int line = 0; + while (done != 0) { line++; @@ -1193,7 +1219,6 @@ load_hex (const char *name) printf ("line %d: invalid hex record information.\n", line); break; } - checksum = count + (addr >> 8) + (addr & 0xff) + type; switch (type) @@ -1201,26 +1226,33 @@ load_hex (const char *name) case 0: for (; count != 0; count--, addr++, checksum += data) { - fscanf (fp, "%2x", &data); - write8 (addr, (UINT8) data); + if (fscanf (fp, "%2x", &data)) + { + write8 (addr, (UINT8) data); + } + else + { + printf ("line %d: hex record data inconsistent with count field.\n", line); + break; + } } checksum = (-checksum) & 0xff; - fscanf (fp, "%2x", &data); - if (data != checksum) + + if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) { - printf ("line %d: invalid hex record checksum.\n", line); + printf ("line %d: hex record checksum missing or invalid.\n", line); done = 0; break; } - (void) fgetc (fp); /* skip CR/LF/NULL */ + fscanf (fp, "%*[\r\n]"); /* skip any form of line ending */ break; case 1: checksum = (-checksum) & 0xff; - fscanf (fp, "%2x", &data); - if (data != checksum) - printf ("line %d: invalid hex record checksum \n", line); + + if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) + printf ("line %d: hex record checksum missing or invalid.\n", line); done = 0; break; @@ -1232,27 +1264,18 @@ load_hex (const char *name) } } - fclose (fp); + (void) fclose (fp); return 0; } int -load_s19 (const char *name) +load_s19 (FILE *fp) { - FILE *fp; int count, addr, type, data, checksum; int done = 1; int line = 0; - fp = file_open (NULL, name, "r"); - - if (fp == NULL) - { - printf ("failed to open S-record file %s.\n", name); - return 1; - } - while (done != 0) { line++; @@ -1270,26 +1293,32 @@ load_s19 (const char *name) case 1: for (count -= 3; count != 0; count--, addr++, checksum += data) { - fscanf (fp, "%2x", &data); - write8 (addr, (UINT8) data); + if (fscanf (fp, "%2x", &data)) + { + write8 (addr, (UINT8) data); + } + else + { + printf ("line %d: S record data inconsistent with count field.\n", line); + break; + } } checksum = (~checksum) & 0xff; - fscanf (fp, "%2x", &data); - if (data != checksum) + + if ( (fscanf (fp, "%2x", &data)) || (data != checksum) ) { - printf ("line %d: invalid S record checksum.\n", line); + printf ("line %d: S record checksum missing or invalid.\n", line); done = 0; break; } - (void) fgetc (fp); /* skip CR/LF/NULL */ + fscanf (fp, "%*[\r\n]"); /* skip any form of line ending */ break; case 9: checksum = (~checksum) & 0xff; - fscanf (fp, "%2x", &data); - if (data != checksum) - printf ("line %d: invalid S record checksum.\n", line); + if ( (fscanf (fp, "%2x", &data)) || (data != checksum) ) + printf ("line %d: S record checksum missing or invalid.\n", line); done = 0; break; @@ -1300,12 +1329,11 @@ load_s19 (const char *name) } } - fclose (fp); + (void) fclose (fp); return 0; } - void monitor_call (unsigned int flags) { @@ -1352,10 +1380,10 @@ monitor_return (void) const char * absolute_addr_name (absolute_address_t addr) { - static char buf[256], *bufptr; - const char *name; + static char buf[256], *bufptr; + const char *name; - bufptr = buf; + bufptr = buf; bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF); @@ -1363,19 +1391,18 @@ absolute_addr_name (absolute_address_t addr) if (name) bufptr += sprintf (bufptr, " <%-16.16s>", name); - return buf; - + return buf; } const char * monitor_addr_name (target_addr_t target_addr) { - static char buf[256], *bufptr; - const char *name; - absolute_address_t addr = to_absolute (target_addr); + static char buf[256], *bufptr; + const char *name; + absolute_address_t addr = to_absolute (target_addr); - bufptr = buf; + bufptr = buf; bufptr += sprintf (bufptr, "0x%04X", target_addr); @@ -1383,33 +1410,33 @@ monitor_addr_name (target_addr_t target_addr) if (name) bufptr += sprintf (bufptr, " <%s>", name); - return buf; + return buf; } static void monitor_signal (int sigtype) { - (void) sigtype; - putchar ('\n'); - monitor_on = 1; + (void) sigtype; + putchar ('\n'); + monitor_on = 1; } void monitor_init (void) { - int tmp; - extern int debug_enabled; - target_addr_t a; + int tmp; + extern int debug_enabled; + target_addr_t a; - fctab[0].entry_point = read16 (0xfffe); - memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs)); - current_function_call = &fctab[0]; + fctab[0].entry_point = read16 (0xfffe); + memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs)); + current_function_call = &fctab[0]; - auto_break_insn_count = 0; - monitor_on = debug_enabled; - signal (SIGINT, monitor_signal); + auto_break_insn_count = 0; + monitor_on = debug_enabled; + signal (SIGINT, monitor_signal); } From 1369c30208e9d571771db67727506e26fdae58d4 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 1 Mar 2015 20:38:37 +0000 Subject: [PATCH 11/71] Add .name fields to device structures for imux, ioexpand; missed in earlier commit. --- imux.c | 1 + ioexpand.c | 1 + 2 files changed, 2 insertions(+) diff --git a/imux.c b/imux.c index 1d5ba37..494c2f6 100644 --- a/imux.c +++ b/imux.c @@ -120,6 +120,7 @@ void imux_assert (struct hw_device *dev, unsigned int sig) struct hw_class imux_class = { + .name = "imux", .readonly = 0, .reset = imux_reset, .read = imux_read, diff --git a/ioexpand.c b/ioexpand.c index 25e99d3..8eaae82 100644 --- a/ioexpand.c +++ b/ioexpand.c @@ -73,6 +73,7 @@ void ioexpand_write (struct hw_device *dev, unsigned long addr, U8 val) struct hw_class ioexpand_class = { + .name = "ioexpand", .readonly = 0, .reset = ioexpand_reset, .read = ioexpand_read, From 608f5e6b3dbacae5475242ad138f23e9006c31b9 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 1 Mar 2015 23:38:42 +0000 Subject: [PATCH 12/71] Make "undefined" regions display more consistently in dump_machine(). --- machine.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/machine.c b/machine.c index 067c443..19cc9f5 100644 --- a/machine.c +++ b/machine.c @@ -303,8 +303,8 @@ void dump_machine (void) for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++) { struct bus_map *map = &busmaps[mapno]; - if ((map->devid == prev_devid) && (map->offset == prev_offset) - && (map->flags == prev_flags)) + if ( (map->devid == prev_devid) && (map->flags == prev_flags) && + ((map->offset == prev_offset) || (map->devid == INVALID_DEVID)) ) { /* nothing interesting to report */ if (! dot_dot) From 53833725f3f8fbf42a19e6d33e110a839b53e023 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 3 Mar 2015 21:46:14 +0000 Subject: [PATCH 13/71] Fix cut/n/paste errors in S19 image load. --- monitor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/monitor.c b/monitor.c index 8a52390..96ab702 100644 --- a/monitor.c +++ b/monitor.c @@ -1306,7 +1306,7 @@ load_s19 (FILE *fp) checksum = (~checksum) & 0xff; - if ( (fscanf (fp, "%2x", &data)) || (data != checksum) ) + if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) { printf ("line %d: S record checksum missing or invalid.\n", line); done = 0; @@ -1317,7 +1317,7 @@ load_s19 (FILE *fp) case 9: checksum = (~checksum) & 0xff; - if ( (fscanf (fp, "%2x", &data)) || (data != checksum) ) + if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) printf ("line %d: S record checksum missing or invalid.\n", line); done = 0; break; From 16304c1b7bd1e25a32d4de9c7f6bb5673a91dec1 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 3 Mar 2015 22:17:40 +0000 Subject: [PATCH 14/71] Modify ioexpand to accept an offset when mapping a device. Example usage: map ioexpand over a ROM, use one slot for I/O and map the remaining slots to the "underlying" ROM by supplying an offset when mapping each slot. --- eon.c | 10 +++++----- ioexpand.c | 31 +++++++++++++++++++++---------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/eon.c b/eon.c index 9406975..29331c9 100644 --- a/eon.c +++ b/eon.c @@ -72,17 +72,17 @@ void eon2_init (const char *boot_rom_file) Each device is allocated only 8 bytes. */ iodev = ioexpand_create (); device_define (iodev, 0, 0xFF00, 128, MAP_READWRITE); - ioexpand_attach (iodev, 0, serial_create ()); - ioexpand_attach (iodev, 1, disk_create ("disk.bin", ram_dev)); - ioexpand_attach (iodev, 2, mmudev); - ioexpand_attach (iodev, 3, intdev = imux_create (1)); + ioexpand_attach (iodev, 0, 0, serial_create ()); + ioexpand_attach (iodev, 1, 0, disk_create ("disk.bin", ram_dev)); + ioexpand_attach (iodev, 2, 0, mmudev); + ioexpand_attach (iodev, 3, 0, intdev = imux_create (1)); /* 4 = config EEPROM */ /* 5 = video display */ /* 6 = battery-backed clock */ /* 7 = power control (reboot/off) */ /* 8 = periodic timer/oscillator */ /* 9 = hostfile (for debug only) */ - ioexpand_attach (iodev, 9, hostfile_create ("hostfile", O_RDWR)); + ioexpand_attach (iodev, 9, 0, hostfile_create ("hostfile", O_RDWR)); /* etc. up to device 15 */ /* May need to define an I/O _multiplexer_ to support more than 16 devices */ diff --git a/ioexpand.c b/ioexpand.c index 8eaae82..939535b 100644 --- a/ioexpand.c +++ b/ioexpand.c @@ -22,10 +22,11 @@ #include #include "machine.h" -/* An I/O expander allows a single, 128-byte region to be shared among multiple -devices. It subdivides the region into 16 8-byte subdevices. It is needed -to work around the inability of the system bus to handle attaching devices -less than 128 bytes wide. */ +/* An I/O expander subdivides a single, 128-byte region into 16, 8-byte slots each +of which can hold a device. It is needed to work around the inability of the system +bus to handle attaching devices less than 128 bytes in size. + +When mapping a slot, an offset can be applied to the underlying device. An example application is to make the I/O expander occupy fewer than 128 bytes by mapping one or more slots to a large underlying ROM. */ #define NR_IOEXPAND 16 #define IO_WINDOW 8 @@ -33,13 +34,15 @@ less than 128 bytes wide. */ struct ioexpand { struct hw_device *ios[NR_IOEXPAND]; + unsigned long offset[NR_IOEXPAND]; }; -void ioexpand_attach (struct hw_device *expander_dev, int slot, struct hw_device *io_dev) +void ioexpand_attach (struct hw_device *expander_dev, int slot, unsigned long offset, struct hw_device *io_dev) { struct ioexpand *iom = (struct ioexpand *)expander_dev->priv; iom->ios[slot] = io_dev; + iom->offset[slot] = offset; } void ioexpand_reset (struct hw_device *dev) @@ -56,19 +59,25 @@ void ioexpand_reset (struct hw_device *dev) U8 ioexpand_read (struct hw_device *dev, unsigned long addr) { struct ioexpand *iom = (struct ioexpand *)dev->priv; - dev = iom->ios[addr / IO_WINDOW]; + int slot = addr / IO_WINDOW; + dev = iom->ios[slot]; if (!dev) sim_error ("expander read from %04X has no backing device\n", addr); - return dev->class_ptr->read (dev, addr % IO_WINDOW); + + addr = (addr % IO_WINDOW) + iom->offset[slot]; + return dev->class_ptr->read (dev, addr); } void ioexpand_write (struct hw_device *dev, unsigned long addr, U8 val) { struct ioexpand *iom = (struct ioexpand *)dev->priv; - dev = iom->ios[addr / IO_WINDOW]; + int slot = addr / IO_WINDOW; + dev = iom->ios[slot]; if (!dev) sim_error ("expander write %02X to %04X has no backing device\n", val, addr); - dev->class_ptr->write (dev, addr % IO_WINDOW, val); + + addr = (addr % IO_WINDOW) + iom->offset[slot]; + dev->class_ptr->write (dev, addr, val); } struct hw_class ioexpand_class = @@ -84,7 +93,9 @@ struct hw_device *ioexpand_create (void) { int i; struct ioexpand *iom = malloc (sizeof (struct ioexpand)); - for (i=0; i < NR_IOEXPAND; i++) + for (i=0; i < NR_IOEXPAND; i++) { iom->ios[i] = NULL; + iom->offset[i] = 0; + } return device_attach (&ioexpand_class, BUS_MAP_SIZE, iom); } From fc4f93790a61db5f68671823e170271295c1f1c5 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Wed, 4 Mar 2015 20:40:28 +0000 Subject: [PATCH 15/71] Create new file miscsbc.c for some new machine definitions. Move eon_fault() to fault() and move it to machine.c. Revise README accordingly. --- Makefile.am | 2 +- README | 14 ++-- eon.c | 25 +----- machine.c | 22 +++++ machine.h | 2 + miscsbc.c | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 275 insertions(+), 28 deletions(-) create mode 100644 miscsbc.c diff --git a/Makefile.am b/Makefile.am index 6b81467..52d68f7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ m6809_run_SOURCES = \ - 6809.c main.c monitor.c machine.c eon.c wpc.c \ + 6809.c main.c monitor.c machine.c eon.c wpc.c miscsbc.c \ symtab.c command.c fileio.c wpclib.c imux.c \ ioexpand.c mmu.c timer.c serial.c disk.c \ 6809.h config.h eon.h machine.h monitor.h wpclib.h diff --git a/README b/README index 400cc24..376cbc7 100644 --- a/README +++ b/README @@ -38,8 +38,9 @@ which says what types of I/O devices are mapped into the 6809's address space and how they can be accessed. Adding support for a new machine is fairly easy. -There are 3 builtin machine types at present. The default, -called 'simple', assumes that you have a full 64KB of RAM, +There are 5 builtin machine types at present: + +* 'simple' - assumes that you have a full 64KB of RAM, minus some input/output functions mapped at $FF00 (see I/O below). If you compile a program with gcc6809 with no special linker option, you'll get an S-record file that is suitable for running @@ -53,18 +54,21 @@ gcc6809 also has a builtin notion of which addresses are used for text and data. The simple machine enforces this and will "fault" on invalid accesses. -The second machine is 'wpc', and is an emulation of the +* 'wpc' - an emulation of the Williams Pinball Controller which was the impetus for me working on the compiler in the first place. -The third machine, still in development, is called 'eon' +* 'eon' (and 'eon2') - still in development, is called 'eon' (for Eight-O-Nine). It is similar to simple but has some more advanced I/O capabilities, like a larger memory space that can be paged in/out, and a disk emulation for programs that wants to have persistence. -TODO : Would anyone be interested in a CoCo machine type? +* 'multicomp09' - see miscsbc.c for details +* 'smii' - see miscsbc.c for details + +TODO : Would anyone be interested in a CoCo machine type? ----------------------------------------------------------------- Faults diff --git a/eon.c b/eon.c index 29331c9..bb084c2 100644 --- a/eon.c +++ b/eon.c @@ -1,24 +1,7 @@ - #include #include "machine.h" #include "eon.h" -extern int system_running; - - -void eon_fault (unsigned int addr, unsigned char type) -{ - if (system_running) - { - sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ()); -#if 0 - fault_addr = addr; - fault_type = type; - irq (); -#endif - } -} - /** * Initialize the EON machine. @@ -106,7 +89,7 @@ void simple_init (const char *boot_rom_file) struct machine eon_machine = { .name = "eon", - .fault = eon_fault, + .fault = fault, .init = eon_init, .periodic = 0, }; @@ -114,7 +97,7 @@ struct machine eon_machine = struct machine eon2_machine = { .name = "eon2", - .fault = eon_fault, + .fault = fault, .init = eon2_init, .periodic = 0, }; @@ -122,9 +105,7 @@ struct machine eon2_machine = struct machine simple_machine = { .name = "simple", - .fault = eon_fault, + .fault = fault, .init = simple_init, .periodic = 0, }; - - diff --git a/machine.c b/machine.c index 19cc9f5..fdc083a 100644 --- a/machine.c +++ b/machine.c @@ -333,6 +333,24 @@ void dump_machine (void) } +/********************************************************** + * Simple fault handler + **********************************************************/ + +void fault (unsigned int addr, unsigned char type) +{ + if (system_running) + { + sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ()); +#if 0 + fault_addr = addr; + fault_type = type; + irq (); +#endif + } +} + + /**********************************************************/ void null_reset (struct hw_device *dev) @@ -600,6 +618,8 @@ void machine_init (const char *machine_name, const char *boot_rom_file) extern struct machine eon_machine; extern struct machine eon2_machine; extern struct machine wpc_machine; + extern struct machine smii_machine; + extern struct machine multicomp09_machine; int i; /* Initialize CPU maps, so that no CPU addresses map to @@ -613,6 +633,8 @@ void machine_init (const char *machine_name, const char *boot_rom_file) else if (machine_match (machine_name, boot_rom_file, &eon_machine)); else if (machine_match (machine_name, boot_rom_file, &eon2_machine)); else if (machine_match (machine_name, boot_rom_file, &wpc_machine)); + else if (machine_match (machine_name, boot_rom_file, &smii_machine)); + else if (machine_match (machine_name, boot_rom_file, &multicomp09_machine)); else exit (1); /* Save the default busmap configuration, before the diff --git a/machine.h b/machine.h index 123ad66..114816a 100644 --- a/machine.h +++ b/machine.h @@ -151,4 +151,6 @@ struct hw_device *rom_create (const char *filename, unsigned int maxsize); struct hw_device *console_create (void); struct hw_device *disk_create (const char *backing_file, struct hw_device *ram_dev); +void fault (unsigned int addr, unsigned char type); + #endif /* _M6809_MACHINE_H */ diff --git a/miscsbc.c b/miscsbc.c new file mode 100644 index 0000000..8ae16da --- /dev/null +++ b/miscsbc.c @@ -0,0 +1,238 @@ +#include +#include "machine.h" +// for symtab stuff? +#include "6809.h" + +// for smii console +int smii_i_avail = 1; +int smii_o_busy = 0; + + +/******************************************************************** + * The Scroungemaster II machine, a platform + * for 6809 CamelForth. See + * Brad Rodriguez http://www.camelforth.com/page.php?6 + * and + * http://www.bradrodriguez.com/papers/impov3.htm + ********************************************************************/ + +// by inspection command read (should be address 0x7c02) comes in with addr=0x8d +// TODO no way to check for "char available" and so smii_i_busy is always true and +// console input is blocking. +U8 smii_console_read (struct hw_device *dev, unsigned long addr) +{ + switch (addr) + { + case 0x02: // SCCACMD + // on output make it seem busy for several polls + smii_o_busy = smii_o_busy == 0 ? 0 : (smii_o_busy + 1)%4; + // printf("02 smii_o_busy = %d return 0x%02x\n",smii_o_busy,(smii_i_avail & 1) | (smii_o_busy == 0 ? 4 : 0)); + return (smii_i_avail & 1) | (smii_o_busy == 0 ? 4 : 0); + case 0x03: // SCCADTA + return getchar(); + default: + printf("In smii_console_read with addr=0x%08x\n", addr); + return 0x42; + } +} + + +void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) +{ + switch (addr) + { + case 0x03: // SCCADTA + if(smii_o_busy != 0) printf("Oops! Write to busy UART\n"); + smii_o_busy = 1; + putchar(val); + break; + default: + printf("In smii_console_write with addr=0x%08x val=0x%02x\n",addr, val); + } +} + + +void smii_init (const char *boot_rom_file) +{ + struct hw_device *smii_console; + + /* RAM from 0 to 7BFF */ + device_define ( ram_create (0x7C00), 0, + 0x0000, 0x7C00, MAP_READWRITE ); + + /* The address space 8000-DFFF provides aliases of the ROM + There is write-only mapping logic for 8 RAM pages and this + is usually accessed by writes to addresses 8000,9000..F000 + + TODO at the moment the CamelForth image does writes to + these addresses at startup. Since the model is strict + these addresses are read-only and the write causes a + trap. Either need to implement a device on each page + to capture them OR adjust the CamelForth image. The + former would be the most sound approach. + + Before doing this, though, clean up the exception + handling. + */ + + /* ROM from E000 to FFFF */ + device_define (rom_create (boot_rom_file, 0x2000), 0, + 0xE000, 0x2000, MAP_READABLE); + + /* Make debug output more informative */ + // ?? haven't seen this work yet.. + sym_add(&internal_symtab, "SCCACMD", to_absolute(0x7c02), 0); + sym_add(&internal_symtab, "SCCADTA", to_absolute(0x7c03), 0); + + /* I/O console at 7C00 + * SCCACMD at 0x7C02 + * SCCADTA at 0x7C03 + */ + + // flag inch_avail + // counter outch_busy init 0 + + // on read from SCCACMD if inch_avail set bit 0. If outch_busy=0 set bit 2. + // if outch_busy!=0, increment it module 4 (ie, it counts up to 4 then stops at 0) + // + // on read from SCCADTA expect inch_avail to be true else fatal error. Return char. + // + // on write to SCCADTA expect outch_busy=0 else fatal error, increment outch_busy (to 1) + + // need to mimic the hardware that is controlled like this: + // CODE KEY \ -- c get char from serial port + // 6 # ( D) PSHS, BEGIN, SCCACMD LDB, 1 # ANDB, NE UNTIL, + // SCCADTA LDB, CLRA, NEXT ;C + // + // CODE KEY? \ -- f return true if char waiting + // 6 # ( D) PSHS, CLRA, SCCACMD LDB, 1 # ANDB, + // NE IF, -1 # LDB, THEN, NEXT ;C + // + // CODE EMIT \ c -- output character to serial port + // BEGIN, SCCACMD LDA, 4 # ANDA, NE UNTIL, + // SCCADTA STB, 6 # ( D) PULS, NEXT ;C + + smii_console = console_create(); + smii_console->class_ptr->read = smii_console_read; + smii_console->class_ptr->write = smii_console_write; + + device_define ( smii_console, 0, + 0x7C00, BUS_MAP_SIZE, MAP_READWRITE ); +} + + +struct machine smii_machine = +{ + .name = "smii", + .fault = fault, + .init = smii_init, + .periodic = 0, +}; + + +/******************************************************************** + * The Multicomp 6809 machine, a platform for Dragon BASIC. + * This version has 1 serial port, 56K RAM and 8K ROM + * The serial port is in a "hole" at 0xFFD0/0xFFD1 + * See: + * Grant Searle http://searle.hostei.com/grant/Multicomp/index.html + * + ********************************************************************/ + +// console input is blocking. +U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) +{ + switch (addr) + { + case 00: + // status bit + return 0xff; + case 01: + return getchar(); + default: + printf("In console_read with addr=0x%08x\n", addr); + return 0x42; + } +} + +void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 val) +{ + switch (addr) + { + case 00: + printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); + break; + + case 01: + putchar(val); + break; + + default: + printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); + } +} + + +void multicomp09_init (const char *boot_rom_file) +{ + struct hw_device *multicomp09_console; + struct hw_device *iodev; + struct hw_device *romdev; + int i; + + /* RAM from 0 to DFFF */ + device_define ( ram_create (0xE000), 0, + 0x0000, 0xE000, MAP_READWRITE ); + + // use the defn below when working on the NXM core-dump bug. + // device_define ( ram_create (0x8000), 0, + // 0x0000, 0x8000, MAP_READWRITE ); + + /* ROM from E000 to FFFF */ + romdev = rom_create (boot_rom_file, 0x2000); + device_define (romdev, 0, + 0xE000, 0x2000, MAP_READABLE); + + /* I/O console */ + multicomp09_console = console_create(); + multicomp09_console->class_ptr->read = multicomp09_console_read; + multicomp09_console->class_ptr->write = multicomp09_console_write; + + /* I/O console at FFD0/FFD1 + Use an ioexpand device at 0xFF80-0xFFFF. + This overlays the ROM mapping and creating it after + the ROM overwrites the ROM's mapping. + The ioexpand provides 16 slots of 8 bytes + Use some for the IO, map the others back to the ROM + In particular, need locations 0xFFF0-0xFFFF mapped + in order to provide the exception vectors. + */ + iodev = ioexpand_create(); + device_define(iodev, 0, 0xFF80, 128, MAP_READWRITE); + for (i=0; i<16; i++) { + if (i==10) { + // 0xFFD0-0xFFD7 + ioexpand_attach(iodev, i, 0, multicomp09_console); + } + else { + // Map to ROM. Read will have an address of 0x0-0xf + // so we need to apply an offset to get it to the + // right place. The offset is from the start of the + // romdev and has nothing to do with the actual + // bus address of the location. + ioexpand_attach(iodev, i, 0x1F80 + (i*8), romdev); + } + } +} + + + + +struct machine multicomp09_machine = +{ + .name = "multicomp09", + .fault = fault, + .init = multicomp09_init, + .periodic = 0, +}; + From 6c9dc8ae6f29302d94e80187809c0ed75543d21d Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 13 Mar 2015 19:50:32 +0000 Subject: [PATCH 16/71] Restore normal buffered keyboard operation on error exit. --- 6809.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/6809.c b/6809.c index d390fc5..87c894d 100644 --- a/6809.c +++ b/6809.c @@ -121,8 +121,10 @@ sim_error (const char *format, ...) if (debug_enabled) monitor_on = 1; - else + else { + keybuffering (1); exit (2); + } } @@ -163,7 +165,7 @@ sim_exit (uint8_t exit_code) fclose (fp); } } - + keybuffering (1); exit (exit_code); } @@ -177,6 +179,7 @@ change_pc (unsigned newPC) { fprintf (stderr, "m6809-run: invalid PC = %04X, previous was %s\n", newPC, monitor_addr_name (PC)); + keybuffering (1); exit (2); } From 3f38f54d00058a8a813466fee03d6be994342f27 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 13 Mar 2015 19:52:05 +0000 Subject: [PATCH 17/71] preserve initial keyboard setup and restore at end. turn off echo on i/o available to target system; target system is now responsible for echo. --- command.c | 36 ++++++++++++++++++++++++++++-------- main.c | 2 ++ 2 files changed, 30 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index b0e608f..75a28f0 100644 --- a/command.c +++ b/command.c @@ -2,12 +2,15 @@ #include "monitor.h" #include "machine.h" #include +#include #ifdef HAVE_TERMIOS_H # include #else #error #endif +struct termios old_tio, new_tio; + typedef struct { unsigned int size; @@ -1326,16 +1329,33 @@ command_exec (FILE *infile) void -keybuffering (int flag) +keybuffering_defaults (void) { - struct termios tio; + /* Extract and save defaults associated with buffered io, create + settings associated with unbuffered io + */ + + /* get the terminal settings for stdin */ + tcgetattr(STDIN_FILENO,&old_tio); - tcgetattr (0, &tio); - if (!flag) /* 0 = no buffering = not default */ - tio.c_lflag &= ~ICANON; - else /* 1 = buffering = default */ - tio.c_lflag |= ICANON; - tcsetattr (0, TCSANOW, &tio); + /* start with the current settings */ + new_tio=old_tio; + + /* disable canonical mode (buffered i/o) and local echo */ + new_tio.c_lflag &=(~ICANON & ~ECHO); +} + +void +keybuffering (int flag) +{ + if (flag) { + printf("**BUFFERED**"); + tcsetattr(STDIN_FILENO,TCSANOW,&old_tio); + } + else { + printf("**UNBUFFERED**"); + tcsetattr(STDIN_FILENO,TCSANOW,&new_tio); + } } diff --git a/main.c b/main.c index 50dfe07..1efe4ac 100644 --- a/main.c +++ b/main.c @@ -404,6 +404,7 @@ main (int argc, char *argv[]) monitor_init (); command_init (); + keybuffering_defaults (); keybuffering (0); /* Now, iterate through the instructions. @@ -448,5 +449,6 @@ main (int argc, char *argv[]) } sim_exit (0); + keybuffering (1); return 0; } From 8e34043303950533870a334f69b407aa8060ffba Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 13 Mar 2015 19:53:58 +0000 Subject: [PATCH 18/71] Add quiet device to allow writes to ROM without error. Tweak serial routines to fix-up keyboard codes for target machines that expect a DOS-like 0x0d as the line ending. --- miscsbc.c | 89 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 75 insertions(+), 14 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 8ae16da..8312825 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -21,6 +21,7 @@ int smii_o_busy = 0; // console input is blocking. U8 smii_console_read (struct hw_device *dev, unsigned long addr) { + unsigned char ch; switch (addr) { case 0x02: // SCCACMD @@ -29,7 +30,11 @@ U8 smii_console_read (struct hw_device *dev, unsigned long addr) // printf("02 smii_o_busy = %d return 0x%02x\n",smii_o_busy,(smii_i_avail & 1) | (smii_o_busy == 0 ? 4 : 0)); return (smii_i_avail & 1) | (smii_o_busy == 0 ? 4 : 0); case 0x03: // SCCADTA - return getchar(); + ch = getchar(); + // key conversions to make keyboard look DOS-like + if (ch == 127) ch = 8; //backspace + if (ch == 10) ch = 13; //cr + return ch; default: printf("In smii_console_read with addr=0x%08x\n", addr); return 0x42; @@ -41,6 +46,9 @@ void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) { switch (addr) { + case 0x00: + // UART setup. Not emulated; just ignore it. + break; case 0x03: // SCCADTA if(smii_o_busy != 0) printf("Oops! Write to busy UART\n"); smii_o_busy = 1; @@ -52,32 +60,81 @@ void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) } +void quiet_reset (struct hw_device *dev) +{ +} + +U8 quiet_read (struct hw_device *dev, unsigned long addr) +{ + char *buf = dev->priv; + char val = buf[addr]; + // printf("In quiet read with address 0x%x return data 0x%x\n",addr,val); + return val; +} + +// BUG! For image file load, the quiet_write also needs to work, BUT it must +// act like ROM for CPU access. Not sure if that is achieved here. +void quiet_write (struct hw_device *dev, unsigned long addr, U8 val) +{ + char *buf = dev->priv; + // printf("In quiet write with address 0x%x data 0x%x\n",addr,val); + buf[addr]= val; +} + +struct hw_class quiet_class = +{ + .name = "quiet-device", + .readonly = 0, + .reset = quiet_reset, + .read = quiet_read, + .write = quiet_write, +}; + +struct hw_device *quiet_create (void) +{ + return device_attach (&quiet_class, 0, NULL); +} + + void smii_init (const char *boot_rom_file) { - struct hw_device *smii_console; + struct hw_device *smii_console, *rom, *quiet; /* RAM from 0 to 7BFF */ device_define ( ram_create (0x7C00), 0, 0x0000, 0x7C00, MAP_READWRITE ); + /* ROM from E000 to FFFF */ + rom = rom_create (boot_rom_file, 0x2000); + device_define (rom , 0, + 0xE000, 0x2000, MAP_READABLE); + /* The address space 8000-DFFF provides aliases of the ROM There is write-only mapping logic for 8 RAM pages and this is usually accessed by writes to addresses 8000,9000..F000 - TODO at the moment the CamelForth image does writes to - these addresses at startup. Since the model is strict - these addresses are read-only and the write causes a - trap. Either need to implement a device on each page - to capture them OR adjust the CamelForth image. The - former would be the most sound approach. + The CamelForth image does writes to those addresses at + in order to initialise the mapping hardware, but makes + no further use of it. Since the model is strict the ROM + is read-only and the write causes a trap. - Before doing this, though, clean up the exception - handling. + To avoid the trap, assign a device that ignores writes + without error, and maps reads to the ROM. */ + quiet = quiet_create(); + /* Allow quiet device to access ROM storage */ + quiet->priv = rom->priv; + + device_define(quiet, 0, 0x8000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0, 0x9000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0, 0xA000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0, 0xB000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0, 0xC000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0, 0xD000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0x0000, 0xE000, BUS_MAP_SIZE, MAP_READWRITE); + device_define(quiet, 0x1000, 0xF000, BUS_MAP_SIZE, MAP_READWRITE); + - /* ROM from E000 to FFFF */ - device_define (rom_create (boot_rom_file, 0x2000), 0, - 0xE000, 0x2000, MAP_READABLE); /* Make debug output more informative */ // ?? haven't seen this work yet.. @@ -142,13 +199,17 @@ struct machine smii_machine = // console input is blocking. U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) { + unsigned char ch; switch (addr) { case 00: // status bit return 0xff; case 01: - return getchar(); + ch = getchar(); + if (ch == 127) return 8; // rubout->backspace + if (ch == 10) return 13; // LF->CR + return ch; default: printf("In console_read with addr=0x%08x\n", addr); return 0x42; From 49fa947699341f303b7765cd7203087d5a660e75 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 13 Mar 2015 20:08:21 +0000 Subject: [PATCH 19/71] oops. Remove debug prints from keybuffering(). --- command.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/command.c b/command.c index 75a28f0..1c06aaf 100644 --- a/command.c +++ b/command.c @@ -1349,11 +1349,9 @@ void keybuffering (int flag) { if (flag) { - printf("**BUFFERED**"); tcsetattr(STDIN_FILENO,TCSANOW,&old_tio); } else { - printf("**UNBUFFERED**"); tcsetattr(STDIN_FILENO,TCSANOW,&new_tio); } } From 51468112caf1a468b04f1fb378cede4bdf426964 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Wed, 18 Mar 2015 23:42:31 +0000 Subject: [PATCH 20/71] Add a new MAP_IGNOREWRITE and use it for pages of smii machine so that the write-only registers do not corrupt the ROM. Tidy up cpu_write. --- machine.c | 36 +++++++++++++++++++++-------- machine.h | 4 ++++ miscsbc.c | 69 ++++++++++++++----------------------------------------- 3 files changed, 48 insertions(+), 61 deletions(-) diff --git a/machine.c b/machine.c index fdc083a..8554095 100644 --- a/machine.c +++ b/machine.c @@ -45,17 +45,19 @@ U16 fault_addr; U8 fault_type; -int system_running = 0; +/* set after CPU reset and never cleared; shows that + system initialisation has completed */ +int cpu_running = 0; void cpu_is_running (void) { - system_running = 1; + cpu_running = 1; } void do_fault (unsigned int addr, unsigned int type) { - if (system_running) + if (cpu_running) machine->fault (addr, type); } @@ -222,7 +224,7 @@ U8 cpu_read8 (unsigned int addr) struct hw_class *class_ptr = dev->class_ptr; unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE; - if (system_running && !(map->flags & MAP_READABLE)) + if (cpu_running && !(map->flags & MAP_READABLE)) machine->fault (addr, FAULT_NOT_READABLE); command_read_hook (absolute_from_reladdr (map->devid, phy_addr)); return (*class_ptr->read) (dev, phy_addr); @@ -235,7 +237,7 @@ U16 cpu_read16 (unsigned int addr) struct hw_class *class_ptr = dev->class_ptr; unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE; - if (system_running && !(map->flags & MAP_READABLE)) + if (cpu_running && !(map->flags & MAP_READABLE)) do_fault (addr, FAULT_NOT_READABLE); command_read_hook (absolute_from_reladdr (map->devid, phy_addr)); return ((*class_ptr->read) (dev, phy_addr) << 8) @@ -253,10 +255,26 @@ void cpu_write8 (unsigned int addr, U8 val) struct hw_class *class_ptr = dev->class_ptr; unsigned long phy_addr = map->offset + addr % BUS_MAP_SIZE; - if (system_running && !(map->flags & MAP_WRITABLE)) + /* Unlike the read case, where we still return data on + an access error, ignore write data on access error. + The cpu_running check allows ROMs to be loaded at + startup (but maybe it would be better if ROM load + used absolute access so that this routine was not + used at all for that purpose) */ + if (!cpu_running || (map->flags & MAP_WRITABLE)) + { + (*class_ptr->write) (dev, phy_addr, val); + } + else if (map->flags & MAP_IGNOREWRITE) + { + /* silently ignore the write */ + } + else if (cpu_running) + { do_fault (addr, FAULT_NOT_WRITABLE); - (*class_ptr->write) (dev, phy_addr, val); - command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val); + } + /* do this regardless (may trigger watchpoint) */ + command_write_hook (absolute_from_reladdr (map->devid, phy_addr), val); } void abs_write8 (absolute_address_t addr, U8 val) @@ -339,7 +357,7 @@ void dump_machine (void) void fault (unsigned int addr, unsigned char type) { - if (system_running) + if (cpu_running) { sim_error (">>> Page fault: addr=%04X type=%02X PC=%04X\n", addr, type, get_pc ()); #if 0 diff --git a/machine.h b/machine.h index 114816a..44c1946 100644 --- a/machine.h +++ b/machine.h @@ -42,6 +42,10 @@ typedef unsigned long absolute_address_t; #define MAP_WRITABLE 0x2 #define MAP_READWRITE 0x3 +/* Usually, an attempt to write without MAP_WRITABLE will cause a fault. + This allows a write and the data silently ignored (no fault) */ +#define MAP_IGNOREWRITE 0x8 + /* A fixed map cannot be reprogrammed. Attempts to bus_map something differently will silently be ignored. */ diff --git a/miscsbc.c b/miscsbc.c index 8312825..4f595f1 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -47,6 +47,7 @@ void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) switch (addr) { case 0x00: + case 0x02: // UART setup. Not emulated; just ignore it. break; case 0x03: // SCCADTA @@ -60,42 +61,6 @@ void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) } -void quiet_reset (struct hw_device *dev) -{ -} - -U8 quiet_read (struct hw_device *dev, unsigned long addr) -{ - char *buf = dev->priv; - char val = buf[addr]; - // printf("In quiet read with address 0x%x return data 0x%x\n",addr,val); - return val; -} - -// BUG! For image file load, the quiet_write also needs to work, BUT it must -// act like ROM for CPU access. Not sure if that is achieved here. -void quiet_write (struct hw_device *dev, unsigned long addr, U8 val) -{ - char *buf = dev->priv; - // printf("In quiet write with address 0x%x data 0x%x\n",addr,val); - buf[addr]= val; -} - -struct hw_class quiet_class = -{ - .name = "quiet-device", - .readonly = 0, - .reset = quiet_reset, - .read = quiet_read, - .write = quiet_write, -}; - -struct hw_device *quiet_create (void) -{ - return device_attach (&quiet_class, 0, NULL); -} - - void smii_init (const char *boot_rom_file) { struct hw_device *smii_console, *rom, *quiet; @@ -115,25 +80,25 @@ void smii_init (const char *boot_rom_file) The CamelForth image does writes to those addresses at in order to initialise the mapping hardware, but makes - no further use of it. Since the model is strict the ROM + no further use of it. Since the model is strict, the ROM is read-only and the write causes a trap. - To avoid the trap, assign a device that ignores writes - without error, and maps reads to the ROM. - */ - quiet = quiet_create(); - /* Allow quiet device to access ROM storage */ - quiet->priv = rom->priv; - - device_define(quiet, 0, 0x8000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0, 0x9000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0, 0xA000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0, 0xB000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0, 0xC000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0, 0xD000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0x0000, 0xE000, BUS_MAP_SIZE, MAP_READWRITE); - device_define(quiet, 0x1000, 0xF000, BUS_MAP_SIZE, MAP_READWRITE); + To avoid the trap, create 1-page dummy devices at each + location in order to silently ignore the writes. + For locations that alias to ROM, change the attribute so + that writes are ignored. + */ + quiet = null_create(); + device_define(quiet, 0, 0x8000, BUS_MAP_SIZE, MAP_IGNOREWRITE); + device_define(quiet, 0, 0x9000, BUS_MAP_SIZE, MAP_IGNOREWRITE); + device_define(quiet, 0, 0xA000, BUS_MAP_SIZE, MAP_IGNOREWRITE); + device_define(quiet, 0, 0xB000, BUS_MAP_SIZE, MAP_IGNOREWRITE); + device_define(quiet, 0, 0xC000, BUS_MAP_SIZE, MAP_IGNOREWRITE); + device_define(quiet, 0, 0xD000, BUS_MAP_SIZE, MAP_IGNOREWRITE); + + device_define(rom, 0x0000, 0xE000, BUS_MAP_SIZE, MAP_IGNOREWRITE | MAP_READABLE); + device_define(rom, 0x1000, 0xF000, BUS_MAP_SIZE, MAP_IGNOREWRITE | MAP_READABLE); /* Make debug output more informative */ From e6112b736ee38e4d39353986e8304b8f670a43f7 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 3 May 2015 11:26:45 +0100 Subject: [PATCH 21/71] Mostly whitespace changes; a few compilation warning fixes. --- 6809.c | 366 +++++++++++++++++------------------------------------ command.c | 283 ++++++++++++++++------------------------- disk.c | 3 +- fileio.c | 1 - imux.c | 5 - ioexpand.c | 1 - machine.c | 49 ++----- mmu.c | 3 +- monitor.c | 74 +++-------- serial.c | 8 +- timer.c | 2 +- wpc.c | 8 +- 12 files changed, 266 insertions(+), 537 deletions(-) diff --git a/6809.c b/6809.c index 87c894d..0dad214 100644 --- a/6809.c +++ b/6809.c @@ -19,8 +19,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - - #include "6809.h" #include "monitor.h" #include @@ -53,7 +51,6 @@ unsigned int cc_changed = 0; unsigned *index_regs[4] = { &X, &Y, &U, &S }; extern int dump_cycles_on_success; - extern int trace_enabled; extern void irq (void); @@ -76,7 +73,6 @@ void release_irq (unsigned int source) irqs_pending &= ~(1 << source); } - void request_firq (unsigned int source) { /* If the interrupt is not masked, generate @@ -93,24 +89,17 @@ void release_firq (unsigned int source) firqs_pending &= ~(1 << source); } - - -static inline void -check_pc (void) +static inline void check_pc (void) { /* TODO */ } - -static inline void -check_stack (void) +static inline void check_stack (void) { /* TODO */ } - -void -sim_error (const char *format, ...) +void sim_error (const char *format, ...) { va_list ap; @@ -127,16 +116,12 @@ sim_error (const char *format, ...) } } - -unsigned long -get_cycles (void) +unsigned long get_cycles (void) { return total + cpu_period - cpu_clk; } - -void -sim_exit (uint8_t exit_code) +void sim_exit (uint8_t exit_code) { char *s; @@ -169,9 +154,7 @@ sim_exit (uint8_t exit_code) exit (exit_code); } - -static inline void -change_pc (unsigned newPC) +static inline void change_pc (unsigned newPC) { #if 0 /* TODO - will let some RAM execute for trampolines */ @@ -192,17 +175,14 @@ change_pc (unsigned newPC) PC = newPC; } - -static inline unsigned -imm_byte (void) +static inline unsigned imm_byte (void) { unsigned val = read8 (PC); PC++; return val; } -static inline unsigned -imm_word (void) +static inline unsigned imm_word (void) { unsigned val = read16 (PC); PC += 2; @@ -211,8 +191,7 @@ imm_word (void) #define WRMEM(addr, data) write8 (addr, data) -static void -WRMEM16 (unsigned addr, unsigned data) +static void WRMEM16 (unsigned addr, unsigned data) { WRMEM (addr, data >> 8); cpu_clk--; @@ -221,8 +200,7 @@ WRMEM16 (unsigned addr, unsigned data) #define RDMEM(addr) read8 (addr) -static unsigned -RDMEM16 (unsigned addr) +static unsigned RDMEM16 (unsigned addr) { unsigned val = RDMEM (addr) << 8; cpu_clk--; @@ -233,29 +211,25 @@ RDMEM16 (unsigned addr) #define write_stack WRMEM #define read_stack RDMEM -static void -write_stack16 (unsigned addr, unsigned data) +static void write_stack16 (unsigned addr, unsigned data) { write_stack ((addr + 1) & 0xffff, data & 0xff); write_stack (addr, data >> 8); } -static unsigned -read_stack16 (unsigned addr) +static unsigned read_stack16 (unsigned addr) { return (read_stack (addr) << 8) | read_stack ((addr + 1) & 0xffff); } -static void -direct (void) +static void direct (void) { unsigned val = read8 (PC) | DP; PC++; ea = val; } -static void -indexed (void) /* note take 1 extra cycle */ +static void indexed (void) /* note take 1 extra cycle */ { unsigned post = imm_byte (); unsigned *R = index_regs[(post >> 5) & 0x3]; @@ -406,8 +380,7 @@ indexed (void) /* note take 1 extra cycle */ } } -static void -extended (void) +static void extended (void) { unsigned val = read16 (PC); PC += 2; @@ -416,216 +389,182 @@ extended (void) /* external register functions */ -unsigned -get_a (void) +unsigned get_a (void) { return A; } -unsigned -get_b (void) +unsigned get_b (void) { return B; } -unsigned -get_dp (void) +unsigned get_dp (void) { return DP >> 8; } -unsigned -get_x (void) +unsigned get_x (void) { return X; } -unsigned -get_y (void) +unsigned get_y (void) { return Y; } -unsigned -get_s (void) +unsigned get_s (void) { return S; } -unsigned -get_u (void) +unsigned get_u (void) { return U; } -unsigned -get_pc (void) +unsigned get_pc (void) { return PC & 0xffff; } -unsigned -get_d (void) +unsigned get_d (void) { return (A << 8) | B; } -unsigned -get_flags (void) +unsigned get_flags (void) { return EFI; } #ifdef H6309 -unsigned -get_e (void) +unsigned get_e (void) { return E; } -unsigned -get_f (void) +unsigned get_f (void) { return F; } -unsigned -get_w (void) +unsigned get_w (void) { return (E << 8) | F; } -unsigned -get_q (void) +unsigned get_q (void) { return (get_w () << 16) | get_d (); } -unsigned -get_v (void) +unsigned get_v (void) { return V; } -unsigned -get_zero (void) +unsigned get_zero (void) { return 0; } -unsigned -get_md (void) +unsigned get_md (void) { return MD; } #endif -void -set_a (unsigned val) +void set_a (unsigned val) { A = val & 0xff; } -void -set_b (unsigned val) +void set_b (unsigned val) { B = val & 0xff; } -void -set_dp (unsigned val) +void set_dp (unsigned val) { DP = (val & 0xff) << 8; } -void -set_x (unsigned val) +void set_x (unsigned val) { X = val & 0xffff; } -void -set_y (unsigned val) +void set_y (unsigned val) { Y = val & 0xffff; } -void -set_s (unsigned val) +void set_s (unsigned val) { S = val & 0xffff; check_stack (); } -void -set_u (unsigned val) +void set_u (unsigned val) { U = val & 0xffff; } -void -set_pc (unsigned val) +void set_pc (unsigned val) { PC = val & 0xffff; check_pc (); } -void -set_d (unsigned val) +void set_d (unsigned val) { A = (val >> 8) & 0xff; B = val & 0xff; } #ifdef H6309 -void -set_e (unsigned val) +void set_e (unsigned val) { E = val & 0xff; } -void -set_f (unsigned val) +void set_f (unsigned val) { F = val & 0xff; } -void -set_w (unsigned val) +void set_w (unsigned val) { E = (val >> 8) & 0xff; F = val & 0xff; } -void -set_q (unsigned val) +void set_q (unsigned val) { set_w ((val >> 16) & 0xffff); set_d (val & 0xffff); } -void -set_v (unsigned val) +void set_v (unsigned val) { V = val & 0xff; } -void -set_zero (unsigned val) +void set_zero (unsigned val) { } -void -set_md (unsigned val) + +void set_md (unsigned val) { MD = val & 0xff; } #endif - /* handle condition code register */ -unsigned -get_cc (void) +unsigned get_cc (void) { unsigned res = EFI & (E_FLAG | F_FLAG | I_FLAG); @@ -643,8 +582,7 @@ get_cc (void) return res; } -void -set_cc (unsigned arg) +void set_cc (unsigned arg) { EFI = arg & (E_FLAG | F_FLAG | I_FLAG); H = (arg & H_FLAG ? 0x10 : 0); @@ -655,9 +593,7 @@ set_cc (unsigned arg) cc_changed = 1; } - -void -cc_modified (void) +void cc_modified (void) { /* Check for pending interrupts */ if (firqs_pending && !(EFI & F_FLAG)) @@ -667,8 +603,7 @@ cc_modified (void) cc_changed = 0; } -unsigned -get_reg (unsigned nro) +unsigned get_reg (unsigned nro) { unsigned val = 0xff; @@ -725,8 +660,7 @@ get_reg (unsigned nro) return val; } -void -set_reg (unsigned nro, unsigned val) +void set_reg (unsigned nro, unsigned val) { switch (nro) { @@ -784,8 +718,7 @@ set_reg (unsigned nro, unsigned val) /* 8-Bit Accumulator and Memory Instructions */ -static unsigned -adc (unsigned arg, unsigned val) +static unsigned adc (unsigned arg, unsigned val) { unsigned res = arg + val + (C != 0); @@ -796,8 +729,7 @@ adc (unsigned arg, unsigned val) return res; } -static unsigned -add (unsigned arg, unsigned val) +static unsigned add (unsigned arg, unsigned val) { unsigned res = arg + val; @@ -808,8 +740,7 @@ add (unsigned arg, unsigned val) return res; } -static unsigned -and (unsigned arg, unsigned val) +static unsigned and (unsigned arg, unsigned val) { unsigned res = arg & val; @@ -819,8 +750,7 @@ and (unsigned arg, unsigned val) return res; } -static unsigned -asl (unsigned arg) /* same as lsl */ +static unsigned asl (unsigned arg) /* same as lsl */ { unsigned res = arg << 1; @@ -832,8 +762,7 @@ asl (unsigned arg) /* same as lsl */ return res; } -static unsigned -asr (unsigned arg) +static unsigned asr (unsigned arg) { unsigned res = (INT8) arg; @@ -844,8 +773,7 @@ asr (unsigned arg) return res; } -static void -bit (unsigned arg, unsigned val) +static void bit (unsigned arg, unsigned val) { unsigned res = arg & val; @@ -853,8 +781,7 @@ bit (unsigned arg, unsigned val) OV = 0; } -static unsigned -clr (unsigned arg) +static unsigned clr (unsigned arg) { C = N = Z = OV = arg = 0; cpu_clk -= 2; @@ -862,8 +789,7 @@ clr (unsigned arg) return arg; } -static void -cmp (unsigned arg, unsigned val) +static void cmp (unsigned arg, unsigned val) { unsigned res = arg - val; @@ -872,8 +798,7 @@ cmp (unsigned arg, unsigned val) OV = (arg ^ val) & (arg ^ res); } -static unsigned -com (unsigned arg) +static unsigned com (unsigned arg) { unsigned res = arg ^ 0xff; @@ -885,8 +810,7 @@ com (unsigned arg) return res; } -static void -daa (void) +static void daa (void) { unsigned res = A; unsigned msn = res & 0xf0; @@ -906,8 +830,7 @@ daa (void) cpu_clk -= 2; } -static unsigned -dec (unsigned arg) +static unsigned dec (unsigned arg) { unsigned res = (arg - 1) & 0xff; @@ -918,8 +841,7 @@ dec (unsigned arg) return res; } -unsigned -eor (unsigned arg, unsigned val) +unsigned eor (unsigned arg, unsigned val) { unsigned res = arg ^ val; @@ -929,8 +851,7 @@ eor (unsigned arg, unsigned val) return res; } -static void -exg (void) +static void exg (void) { unsigned tmp1 = 0xff; unsigned tmp2 = 0xff; @@ -948,8 +869,7 @@ exg (void) cpu_clk -= 8; } -static unsigned -inc (unsigned arg) +static unsigned inc (unsigned arg) { unsigned res = (arg + 1) & 0xff; @@ -960,8 +880,7 @@ inc (unsigned arg) return res; } -static unsigned -ld (unsigned arg) +static unsigned ld (unsigned arg) { unsigned res = arg; @@ -971,8 +890,7 @@ ld (unsigned arg) return res; } -static unsigned -lsr (unsigned arg) +static unsigned lsr (unsigned arg) { unsigned res = arg >> 1; @@ -984,8 +902,7 @@ lsr (unsigned arg) return res; } -static void -mul (void) +static void mul (void) { unsigned res = (A * B) & 0xffff; @@ -996,8 +913,7 @@ mul (void) cpu_clk -= 11; } -static unsigned -neg (int arg) +static unsigned neg (int arg) { unsigned res = (-arg) & 0xff; @@ -1008,8 +924,7 @@ neg (int arg) return res; } -static unsigned -or (unsigned arg, unsigned val) +static unsigned or (unsigned arg, unsigned val) { unsigned res = arg | val; @@ -1019,8 +934,7 @@ or (unsigned arg, unsigned val) return res; } -static unsigned -rol (unsigned arg) +static unsigned rol (unsigned arg) { unsigned res = (arg << 1) + (C != 0); @@ -1032,8 +946,7 @@ rol (unsigned arg) return res; } -static unsigned -ror (unsigned arg) +static unsigned ror (unsigned arg) { unsigned res = arg; @@ -1046,8 +959,7 @@ ror (unsigned arg) return res; } -static unsigned -sbc (unsigned arg, unsigned val) +static unsigned sbc (unsigned arg, unsigned val) { unsigned res = arg - val - (C != 0); @@ -1058,8 +970,7 @@ sbc (unsigned arg, unsigned val) return res; } -static void -st (unsigned arg) +static void st (unsigned arg) { unsigned res = arg; @@ -1069,8 +980,7 @@ st (unsigned arg) WRMEM (ea, res); } -static unsigned -sub (unsigned arg, unsigned val) +static unsigned sub (unsigned arg, unsigned val) { unsigned res = arg - val; @@ -1081,8 +991,7 @@ sub (unsigned arg, unsigned val) return res; } -static void -tst (unsigned arg) +static void tst (unsigned arg) { unsigned res = arg; @@ -1091,8 +1000,7 @@ tst (unsigned arg) cpu_clk -= 2; } -static void -tfr (void) +static void tfr (void) { unsigned tmp1 = 0xff; unsigned post = imm_byte (); @@ -1105,18 +1013,15 @@ tfr (void) cpu_clk -= 6; } - /* 16-Bit Accumulator Instructions */ -static void -abx (void) +static void abx (void) { X = (X + B) & 0xffff; cpu_clk -= 3; } -static void -addd (unsigned val) +static void addd (unsigned val) { unsigned arg = (A << 8) | B; unsigned res = arg + val; @@ -1128,8 +1033,7 @@ addd (unsigned val) B = res & 0xff; } -static void -cmp16 (unsigned arg, unsigned val) +static void cmp16 (unsigned arg, unsigned val) { unsigned res = arg - val; @@ -1139,8 +1043,7 @@ cmp16 (unsigned arg, unsigned val) OV = ((arg ^ val) & (arg ^ res)) >> 8; } -static void -ldd (unsigned arg) +static void ldd (unsigned arg) { unsigned res = arg; @@ -1150,8 +1053,7 @@ ldd (unsigned arg) OV = 0; } -static unsigned -ld16 (unsigned arg) +static unsigned ld16 (unsigned arg) { unsigned res = arg; @@ -1162,8 +1064,7 @@ ld16 (unsigned arg) return res; } -static void -sex (void) +static void sex (void) { unsigned res = B; @@ -1175,8 +1076,7 @@ sex (void) cpu_clk -= 2; } -static void -std (void) +static void std (void) { unsigned res = (A << 8) | B; @@ -1186,8 +1086,7 @@ std (void) WRMEM16 (ea, res); } -static void -st16 (unsigned arg) +static void st16 (unsigned arg) { unsigned res = arg; @@ -1197,8 +1096,7 @@ st16 (unsigned arg) WRMEM16 (ea, res); } -static void -subd (unsigned val) +static void subd (unsigned val) { unsigned arg = (A << 8) | B; unsigned res = arg - val; @@ -1212,8 +1110,7 @@ subd (unsigned val) /* stack instructions */ -static void -pshs (void) +static void pshs (void) { unsigned post = imm_byte (); @@ -1269,8 +1166,7 @@ pshs (void) } } -static void -pshu (void) +static void pshu (void) { unsigned post = imm_byte (); @@ -1326,8 +1222,7 @@ pshu (void) } } -static void -puls (void) +static void puls (void) { unsigned post = imm_byte (); @@ -1385,8 +1280,7 @@ puls (void) } } -static void -pulu (void) +static void pulu (void) { unsigned post = imm_byte (); @@ -1446,14 +1340,12 @@ pulu (void) /* Miscellaneous Instructions */ -static void -nop (void) +static void nop (void) { cpu_clk -= 2; } -static void -jsr (void) +static void jsr (void) { S = (S - 2) & 0xffff; write_stack16 (S, PC & 0xffff); @@ -1461,8 +1353,7 @@ jsr (void) monitor_call (0); } -static void -rti (void) +static void rti (void) { monitor_return (); cpu_clk -= 6; @@ -1491,8 +1382,7 @@ rti (void) S = (S + 2) & 0xffff; } -static void -rts (void) +static void rts (void) { monitor_return (); cpu_clk -= 5; @@ -1501,8 +1391,7 @@ rts (void) S = (S + 2) & 0xffff; } -void -irq (void) +void irq (void) { EFI |= E_FLAG; S = (S - 2) & 0xffff; @@ -1530,9 +1419,7 @@ irq (void) #endif } - -void -firq (void) +void firq (void) { EFI &= ~E_FLAG; S = (S - 2) & 0xffff; @@ -1547,9 +1434,7 @@ firq (void) #endif } - -void -swi (void) +void swi (void) { cpu_clk -= 19; EFI |= E_FLAG; @@ -1574,8 +1459,7 @@ swi (void) change_pc (read16 (0xfffa)); } -void -swi2 (void) +void swi2 (void) { cpu_clk -= 20; EFI |= E_FLAG; @@ -1599,8 +1483,7 @@ swi2 (void) change_pc (read16 (0xfff4)); } -void -swi3 (void) +void swi3 (void) { cpu_clk -= 20; EFI |= E_FLAG; @@ -1625,8 +1508,7 @@ swi3 (void) } #ifdef H6309 -void -trap (void) +void trap (void) { cpu_clk -= 20; EFI |= E_FLAG; @@ -1651,21 +1533,18 @@ trap (void) } #endif -void -cwai (void) +void cwai (void) { sim_error ("CWAI - not supported yet!"); } -void -sync (void) +void sync (void) { cpu_clk -= 4; sim_error ("SYNC - not supported yet!"); } -static void -orcc (void) +static void orcc (void) { unsigned tmp = imm_byte (); @@ -1673,8 +1552,7 @@ orcc (void) cpu_clk -= 3; } -static void -andcc (void) +static void andcc (void) { unsigned tmp = imm_byte (); @@ -1699,15 +1577,13 @@ andcc (void) #define cond_GT() ((((N^OV) & 0x80) == 0) && (Z != 0)) #define cond_LE() ((((N^OV) & 0x80) != 0) || (Z == 0)) -static void -bra (void) +static void bra (void) { INT8 tmp = (INT8) imm_byte (); change_pc (PC + tmp); } -static void -branch (unsigned cond) +static void branch (unsigned cond) { if (cond) bra (); @@ -1717,15 +1593,13 @@ branch (unsigned cond) cpu_clk -= 3; } -static void -long_bra (void) +static void long_bra (void) { INT16 tmp = (INT16) imm_word (); change_pc (PC + tmp); } -static void -long_branch (unsigned cond) +static void long_branch (unsigned cond) { if (cond) { @@ -1739,8 +1613,7 @@ long_branch (unsigned cond) } } -static void -long_bsr (void) +static void long_bsr (void) { INT16 tmp = (INT16) imm_word (); ea = PC + tmp; @@ -1751,8 +1624,7 @@ long_bsr (void) monitor_call (0); } -static void -bsr (void) +static void bsr (void) { INT8 tmp = (INT8) imm_byte (); ea = PC + tmp; @@ -1763,10 +1635,8 @@ bsr (void) monitor_call (0); } - /* Execute 6809 code for a certain number of cycles. */ -int -cpu_execute (int cycles) +int cpu_execute (int cycles) { unsigned opcode; @@ -3145,8 +3015,7 @@ cpu_execute (int cycles) return cpu_period; } -void -cpu_reset (void) +void cpu_reset (void) { X = Y = S = U = A = B = DP = 0; H = N = OV = C = 0; @@ -3160,10 +3029,9 @@ cpu_reset (void) cpu_is_running (); } -void -print_regs (void) +void print_regs (void) { - char flags[8] = " "; + char flags[9] = " \0"; if (get_cc() & C_FLAG) flags[0] = 'C'; if (get_cc() & V_FLAG) flags[1] = 'V'; if (get_cc() & Z_FLAG) flags[2] = 'Z'; diff --git a/command.c b/command.c index 1c06aaf..858bcaa 100644 --- a/command.c +++ b/command.c @@ -86,9 +86,7 @@ FILE *command_input; /******************** 6809 Functions **********************/ /**********************************************************/ - -void -print_addr (absolute_address_t addr) +void print_addr (absolute_address_t addr) { const char *name; @@ -108,29 +106,22 @@ print_addr (absolute_address_t addr) /*********************** Functions ************************/ /**********************************************************/ -void -syntax_error (const char *string) +void syntax_error (const char *string) { fprintf (stderr, "error: %s\n", string); } - -void -save_value (unsigned long val) +void save_value (unsigned long val) { historytab[history_count++ % MAX_HISTORY] = val; } - -unsigned long -eval_historical (unsigned int id) +unsigned long eval_historical (unsigned int id) { return historytab[id % MAX_HISTORY]; } - -void -assign_virtual (const char *name, unsigned long val) +void assign_virtual (const char *name, unsigned long val) { unsigned long v_val; @@ -154,9 +145,7 @@ assign_virtual (const char *name, unsigned long val) } } - -unsigned long -eval_virtual (const char *name) +unsigned long eval_virtual (const char *name) { unsigned long val; @@ -180,24 +169,20 @@ eval_virtual (const char *name) return val; } - -void -eval_assign (char *expr, unsigned long val) +void eval_assign (char *expr, unsigned long val) { if (*expr == '$') { assign_virtual (expr+1, val); } - else - { - absolute_address_t dst = eval_mem (expr, LVALUE); - abs_write8 (dst, val); - } + else + { + absolute_address_t dst = eval_mem(expr, LVALUE); + abs_write8(dst, (U8) val); + } } - -unsigned long -target_read (absolute_address_t addr, unsigned int size) +unsigned long target_read (absolute_address_t addr, unsigned int size) { switch (size) { @@ -208,9 +193,7 @@ target_read (absolute_address_t addr, unsigned int size) } } - -void -parse_format_flag (const char *flags, unsigned char *formatp) +void parse_format_flag (const char *flags, unsigned char *formatp) { while (*flags) { @@ -229,9 +212,7 @@ parse_format_flag (const char *flags, unsigned char *formatp) } } - -void -parse_size_flag (const char *flags, unsigned int *sizep) +void parse_size_flag (const char *flags, unsigned int *sizep) { while (*flags) { @@ -247,9 +228,7 @@ parse_size_flag (const char *flags, unsigned int *sizep) } } - -char * -match_binary (char *expr, const char *op, char **secondp) +char* match_binary (char *expr, const char *op, char **secondp) { char *p; p = strstr (expr, op); @@ -261,9 +240,7 @@ match_binary (char *expr, const char *op, char **secondp) return expr; } - -int -fold_comparisons (char *expr, unsigned long *value) +int fold_comparisons (char *expr, unsigned long *value) { char *p; if (match_binary (expr, "==", &p)) @@ -275,9 +252,7 @@ fold_comparisons (char *expr, unsigned long *value) return 1; } - -int -fold_binary (char *expr, const char op, unsigned long *valp) +int fold_binary (char *expr, const char op, unsigned long *valp) { char *p; unsigned long val1, val2; @@ -307,8 +282,7 @@ fold_binary (char *expr, const char op, unsigned long *valp) /** * Evaluate a memory expression, as an lvalue or rvalue. */ -unsigned long -eval_mem (char *expr, eval_mode_t mode) +unsigned long eval_mem (char *expr, eval_mode_t mode) { char *p; unsigned long val; @@ -338,7 +312,6 @@ eval_mem (char *expr, eval_mode_t mode) return val; } - /** * Evaluate an expression, given as a string. * The return is the value (rvalue) of the expression. @@ -347,8 +320,7 @@ eval_mem (char *expr, eval_mode_t mode) * - Support typecasts ( {TYPE}ADDR ) * */ -unsigned long -eval (char *expr) +unsigned long eval(char *expr) { char *p; unsigned long val; @@ -391,8 +363,7 @@ eval (char *expr) return val; } - -void brk_enable (breakpoint_t *br, int flag) +void brk_enable(breakpoint_t *br, int flag) { if (br->enabled != flag) { @@ -404,9 +375,7 @@ void brk_enable (breakpoint_t *br, int flag) } } - -breakpoint_t * -brkalloc (void) +breakpoint_t* brkalloc (void) { unsigned int n; for (n = 0; n < MAX_BREAKS; n++) @@ -426,17 +395,13 @@ brkalloc (void) return NULL; } - -void -brkfree (breakpoint_t *br) +void brkfree (breakpoint_t *br) { brk_enable (br, 0); br->used = 0; } - -void -brkfree_temps (void) +void brkfree_temps (void) { unsigned int n; for (n = 0; n < MAX_BREAKS; n++) @@ -446,9 +411,7 @@ brkfree_temps (void) } } - -breakpoint_t * -brkfind_by_addr (absolute_address_t addr) +breakpoint_t* brkfind_by_addr (absolute_address_t addr) { unsigned int n; for (n = 0; n < MAX_BREAKS; n++) @@ -457,15 +420,12 @@ brkfind_by_addr (absolute_address_t addr) return NULL; } -breakpoint_t * -brkfind_by_id (unsigned int id) +breakpoint_t* brkfind_by_id (unsigned int id) { return &breaktab[id]; } - -void -brkprint (breakpoint_t *brkpt) +void brkprint (breakpoint_t *brkpt) { if (!brkpt->used) return; @@ -498,9 +458,7 @@ brkprint (breakpoint_t *brkpt) putchar ('\n'); } - -display_t * -display_alloc (void) +display_t* display_alloc (void) { unsigned int n; for (n = 0; n < MAX_DISPLAYS; n++) @@ -514,15 +472,11 @@ display_alloc (void) } } - -void -display_free (display_t *ds) +void display_free (display_t *ds) { } - -void -print_value (unsigned long val, datatype_t *typep) +void print_value (unsigned long val, datatype_t *typep) { char f[8]; @@ -564,9 +518,7 @@ print_value (unsigned long val, datatype_t *typep) printf (f, val); } - -void -display_print (void) +void display_print (void) { unsigned int n; char comma = '\0'; @@ -588,10 +540,7 @@ display_print (void) putchar ('\n'); } - - -int -print_insn (absolute_address_t addr) +int print_insn (absolute_address_t addr) { char buf[64]; int size = dasm (buf, addr); @@ -599,9 +548,7 @@ print_insn (absolute_address_t addr) return size; } - -void -do_examine (void) +void do_examine (void) { unsigned int n; unsigned int objs_per_line = 16; @@ -654,8 +601,7 @@ do_examine (void) putchar ('\n'); } -void -do_print (char *expr) +void do_print (char *expr) { unsigned long val = eval (expr); printf ("$%d = ", history_count); @@ -667,8 +613,7 @@ do_print (char *expr) save_value (val); } -void -do_set (char *expr) +void do_set (char *expr) { (void)eval (expr); } @@ -677,8 +622,7 @@ do_set (char *expr) #define THREAD_DATA_PC 3 #define THREAD_DATA_ROMBANK 9 -void -print_thread_data (absolute_address_t th) +void print_thread_data (absolute_address_t th) { U8 b; U16 w; @@ -695,11 +639,9 @@ print_thread_data (absolute_address_t th) //printf ("{ <%04X,%02X>", w, b); } - -void -command_change_thread (void) +void command_change_thread (void) { - target_addr_t addr = target_read (thread_current, thread_id_size); + target_addr_t addr = (target_addr_t) target_read(thread_current, thread_id_size); absolute_address_t th = to_absolute (addr); if (th == thread_id) @@ -723,36 +665,27 @@ command_change_thread (void) } } - -void -command_stack_push (unsigned int reason) +void command_stack_push (unsigned int reason) { cmdqueue_t *q = &command_stack[++command_stack_depth]; } - -void -command_stack_pop (void) +void command_stack_pop (void) { cmdqueue_t *q = &command_stack[command_stack_depth]; --command_stack_depth; } - -void -command_stack_add (const char *cmd) +void command_stack_add (const char *cmd) { cmdqueue_t *q = &command_stack[command_stack_depth]; } - -char * -getarg (void) +char* getarg (void) { return strtok (NULL, " \t\n"); } - /****************** Command Handlers ************************/ void cmd_print (void) @@ -764,7 +697,6 @@ void cmd_print (void) do_print ("$"); } - void cmd_set (void) { char *arg = getarg (); @@ -778,7 +710,6 @@ void cmd_set (void) do_set ("$"); } - void cmd_examine (void) { char *arg = getarg (); @@ -813,7 +744,6 @@ void cmd_break (void) brkprint (br); } - void cmd_watch1 (int on_read, int on_write) { char *arg; @@ -851,13 +781,11 @@ void cmd_watch1 (int on_read, int on_write) brkprint (br); } - void cmd_watch (void) { cmd_watch1 (0, 1); } - void cmd_rwatch (void) { cmd_watch1 (1, 0); @@ -868,7 +796,6 @@ void cmd_awatch (void) cmd_watch1 (1, 1); } - void cmd_break_list (void) { unsigned int n; @@ -924,7 +851,6 @@ void cmd_delete (void) if (!arg) { - int n; printf ("Deleting all breakpoints.\n"); for (id = 0; id < MAX_BREAKS; id++) { @@ -974,7 +900,6 @@ void cmd_list (void) lastaddr = addr; } - void cmd_symbol_file (void) { char *arg = getarg (); @@ -982,7 +907,6 @@ void cmd_symbol_file (void) load_map_file (arg); } - void cmd_display (void) { char *arg; @@ -997,7 +921,6 @@ void cmd_display (void) } } - int command_exec_file (const char *filename) { FILE *infile; @@ -1011,7 +934,6 @@ int command_exec_file (const char *filename) return 1; } - void cmd_source (void) { char *arg = getarg (); @@ -1027,12 +949,24 @@ void cmd_regs (void) print_regs(); } +void cmd_pc(void) +{ + char* arg = getarg(); + if (!arg) + { + cmd_regs(); + return; + } + + set_pc(eval_mem(arg, LVALUE)); + cmd_list(); +} + void cmd_vars (void) { for_each_var (NULL); } - void cmd_runfor (void) { char *arg = getarg (); @@ -1047,7 +981,6 @@ void cmd_runfor (void) exit_command_loop = 0; } - void cmd_measure (void) { absolute_address_t addr; @@ -1087,7 +1020,6 @@ void cmd_measure (void) exit_command_loop = 0; } - void cmd_dump_insns (void) { extern int dump_every_insn; @@ -1099,9 +1031,7 @@ void cmd_dump_insns (void) dump_every_insn ? "on" : "off"); } - -void -cmd_trace_dump (void) +void cmd_trace_dump (void) { unsigned int off = (trace_offset + 1) % MAX_TRACE; do { @@ -1121,11 +1051,12 @@ cmd_trace_dump (void) void cmd_dump (void) { + printf("not implemented\n"); } - void cmd_restore (void) { + printf("not implemented\n"); } void cmd_info (void) @@ -1201,6 +1132,8 @@ struct command_name "Restore contents of memory from a file" }, { "i", "info", cmd_info, "Describe machine, devices and address mapping" }, + { "pc", "pc", cmd_pc, + "Set program counter" }, #if 0 { "cl", "clear", cmd_clear }, { "co", "condition", cmd_condition }, @@ -1227,8 +1160,7 @@ void cmd_help (void) } } -command_handler_t -command_lookup (const char *cmd) +command_handler_t command_lookup (const char *cmd) { struct command_name *cn; char *p; @@ -1256,9 +1188,38 @@ command_lookup (const char *cmd) return NULL; } +int print_insn_long (absolute_address_t addr) +{ + char buf[64]; + int i; + int size = dasm(buf, addr); + + const char* name; + + print_device_name(addr >> 28); + putchar(':'); + printf("0x%04X ", addr & 0xFFFFFF); + + for (i = 0; i < size; i++) + printf("%02X", abs_read8(addr + i)); + + for (i = 0; i < 4 - size; i++) + printf(" "); + + name = sym_lookup(&program_symtab, addr); + if (name) + printf(" %-12.12s", name); + else + printf("%-14.14s", ""); + + printf("%s", buf); -void -print_current_insn (void) + putchar ('\n'); + + return size; +} + +void print_current_insn (void) { absolute_address_t addr = to_absolute (get_pc ()); print_addr (addr); @@ -1267,15 +1228,12 @@ print_current_insn (void) putchar ('\n'); } - -int -command_exec (FILE *infile) +int command_exec (FILE *infile) { char buffer[256]; static char prev_buffer[256]; char *cmd; command_handler_t handler; - int rc; do { errno = 0; @@ -1327,10 +1285,9 @@ command_exec (FILE *infile) return 0; } - -void -keybuffering_defaults (void) +void keybuffering_defaults (void) { +#ifndef _MSC_VER /* Extract and save defaults associated with buffered io, create settings associated with unbuffered io */ @@ -1343,22 +1300,22 @@ keybuffering_defaults (void) /* disable canonical mode (buffered i/o) and local echo */ new_tio.c_lflag &=(~ICANON & ~ECHO); +#endif } -void -keybuffering (int flag) +void keybuffering (int flag) { +#ifndef _MSC_VER if (flag) { tcsetattr(STDIN_FILENO,TCSANOW,&old_tio); } else { tcsetattr(STDIN_FILENO,TCSANOW,&new_tio); } +#endif } - -int -command_loop (void) +int command_loop (void) { keybuffering (1); brkfree_temps (); @@ -1390,9 +1347,7 @@ command_loop (void) return (exit_command_loop); } - -void -breakpoint_hit (breakpoint_t *br) +void breakpoint_hit (breakpoint_t *br) { if (br->threaded && (thread_id != br->tid)) return; @@ -1412,17 +1367,13 @@ breakpoint_hit (breakpoint_t *br) monitor_on = !br->keep_running; } - -void -command_trace_insn (target_addr_t addr) +void command_trace_insn (target_addr_t addr) { trace_buffer[trace_offset++] = addr; trace_offset %= MAX_TRACE; } - -void -command_insn_hook (void) +void command_insn_hook (void) { target_addr_t pc; absolute_address_t abspc; @@ -1448,9 +1399,7 @@ command_insn_hook (void) } } - -void -command_read_hook (absolute_address_t addr) +void command_read_hook (absolute_address_t addr) { breakpoint_t *br; @@ -1467,9 +1416,7 @@ command_read_hook (absolute_address_t addr) } } - -void -command_write_hook (absolute_address_t addr, U8 val) +void command_write_hook (absolute_address_t addr, U8 val) { breakpoint_t *br; @@ -1506,9 +1453,7 @@ command_write_hook (absolute_address_t addr, U8 val) } } - -void -command_periodic (void) +void command_periodic (void) { if (stop_after_ms) { @@ -1522,7 +1467,6 @@ command_periodic (void) } } - void pc_virtual (unsigned long *val, int writep) { writep ? set_pc (*val) : (*val = get_pc ()); } @@ -1558,14 +1502,12 @@ void irq_load_virtual (unsigned long *val, int writep) { *val = irq_cycles / IRQ_CYCLE_COUNTS; } - void cycles_virtual (unsigned long *val, int writep) { if (!writep) *val = get_cycles (); } - void et_virtual (unsigned long *val, int writep) { static unsigned long last_cycles = 0; @@ -1574,14 +1516,12 @@ void et_virtual (unsigned long *val, int writep) last_cycles = get_cycles (); } - /** * Update the $irqload virtual register, which tracks the * average number of cycles spent in IRQ. This function * maintains a rolling history of IRQ_CYCLE_COUNTS entries. */ -void -command_exit_irq_hook (unsigned long cycles) +void command_exit_irq_hook (unsigned long cycles) { irq_cycles -= irq_cycle_tab[irq_cycle_entry]; irq_cycles += cycles; @@ -1589,12 +1529,8 @@ command_exit_irq_hook (unsigned long cycles) irq_cycle_entry = (irq_cycle_entry + 1) % IRQ_CYCLE_COUNTS; } - -void -command_init (void) +void command_init (void) { - int rc; - /* Install virtual registers. These are referenced in expressions * using a dollar-sign prefix (e.g. $pc). The value of the * symbol is a pointer to a function (e.g. pc_virtual) which @@ -1622,6 +1558,3 @@ command_init (void) command_input = stdin; (void)command_exec_file (".dbinit"); } - -/* vim: set ts=3: */ -/* vim: set expandtab: */ diff --git a/disk.c b/disk.c index 1a7828c..3bc19e0 100644 --- a/disk.c +++ b/disk.c @@ -70,6 +70,7 @@ void disk_update (struct hw_device *dev) U8 disk_read (struct hw_device *dev, unsigned long addr) { struct disk_priv *disk = (struct disk_priv *)dev->priv; + return 0; } void disk_write (struct hw_device *dev, unsigned long addr, U8 val) @@ -79,7 +80,7 @@ void disk_write (struct hw_device *dev, unsigned long addr, U8 val) switch (addr) { case DSK_ADDR: - disk->ram = disk->ramdev->priv + val * SECTOR_SIZE; + disk->ram = (U8*) disk->ramdev->priv + val * SECTOR_SIZE; break; case DSK_SECTOR: disk->offset = val; /* high byte */ diff --git a/fileio.c b/fileio.c index ac0e681..21988b8 100644 --- a/fileio.c +++ b/fileio.c @@ -1,4 +1,3 @@ - #include "6809.h" void diff --git a/imux.c b/imux.c index 494c2f6..371b2f2 100644 --- a/imux.c +++ b/imux.c @@ -55,7 +55,6 @@ void imux_refresh (struct imux *mux) } } - void imux_reset (struct hw_device *dev) { struct imux *mux = (struct imux *)dev->priv; @@ -79,7 +78,6 @@ U8 imux_read (struct hw_device *dev, unsigned long addr) return -1; } - void imux_write (struct hw_device *dev, unsigned long addr, U8 val) { struct imux *mux = (struct imux *)dev->priv; @@ -117,7 +115,6 @@ void imux_assert (struct hw_device *dev, unsigned int sig) imux_refresh (mux); } - struct hw_class imux_class = { .name = "imux", @@ -133,5 +130,3 @@ struct hw_device *imux_create (unsigned int cpu_line) imux->src = cpu_line; return device_attach (&imux_class, BUS_MAP_SIZE, imux); } - - diff --git a/ioexpand.c b/ioexpand.c index 939535b..77da240 100644 --- a/ioexpand.c +++ b/ioexpand.c @@ -37,7 +37,6 @@ struct ioexpand unsigned long offset[NR_IOEXPAND]; }; - void ioexpand_attach (struct hw_device *expander_dev, int slot, unsigned long offset, struct hw_device *io_dev) { struct ioexpand *iom = (struct ioexpand *)expander_dev->priv; diff --git a/machine.c b/machine.c index 8554095..e308dd8 100644 --- a/machine.c +++ b/machine.c @@ -18,7 +18,6 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #include #include #include @@ -49,7 +48,6 @@ U8 fault_type; system initialisation has completed */ int cpu_running = 0; - void cpu_is_running (void) { cpu_running = 1; @@ -61,7 +59,6 @@ void do_fault (unsigned int addr, unsigned int type) machine->fault (addr, type); } - void exit_fault (unsigned int addr, unsigned int type) { monitor_on = debug_enabled; @@ -69,7 +66,6 @@ void exit_fault (unsigned int addr, unsigned int type) exit (1); } - /** * Attach a new device to the bus. Only called during init. */ @@ -87,7 +83,6 @@ struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, return dev; }; - /** * Map a portion of a device into the CPU's address space. */ @@ -103,8 +98,8 @@ void bus_map (unsigned int addr, /* Warn if trying to map too much */ if (addr + len > MAX_CPU_ADDR) { - fprintf (stderr, "warning: mapping %04X bytes into %04X causes overflow\n", - len, addr); + fprintf(stderr, "warning: mapping %04X bytes into %04X causes overflow\n", + len, addr); } /* Round address and length to be multiples of the map unit size. */ @@ -139,13 +134,11 @@ void device_define (struct hw_device *dev, unsigned int flags) { /* Note: len must be a multiple of BUS_MAP_SIZE */ - bus_map (addr, dev->devid, offset, len, flags); + bus_map(addr, dev->devid, offset, len, flags); } - void bus_unmap (unsigned int addr, unsigned int len) { - struct bus_map *map; unsigned int start, count; /* Round address and length to be multiples of the map unit size. */ @@ -161,7 +154,6 @@ void bus_unmap (unsigned int addr, unsigned int len) sizeof (struct bus_map) * count); } - /** * Generate a page fault. ADDR says which address was accessed * incorrectly. TYPE says what kind of violation occurred. @@ -183,22 +175,17 @@ static struct hw_device *find_device (unsigned int addr, unsigned char id) return device_table[id]; } - -void -print_device_name (unsigned int devno) +void print_device_name (unsigned int devno) { struct hw_device *dev = device_table[devno]; printf ("%02X", devno); } - -absolute_address_t -absolute_from_reladdr (unsigned int device, unsigned long reladdr) +absolute_address_t absolute_from_reladdr (unsigned int device, unsigned long reladdr) { return (device * 0x10000000L) + reladdr; } - U8 abs_read8 (absolute_address_t addr) { unsigned int id = addr >> 28; @@ -208,7 +195,6 @@ U8 abs_read8 (absolute_address_t addr) return (*class_ptr->read) (dev, phy_addr); } - /** * Called by the CPU to read a byte. * This is the bottleneck in terms of performance. Consider @@ -244,7 +230,6 @@ U16 cpu_read16 (unsigned int addr) | (*class_ptr->read) (dev, phy_addr+1); } - /** * Called by the CPU to write a byte. */ @@ -279,17 +264,14 @@ void cpu_write8 (unsigned int addr, U8 val) void abs_write8 (absolute_address_t addr, U8 val) { - unsigned int id = addr >> 28; - unsigned long phy_addr = addr & 0xFFFFFFF; + unsigned int id = addr >> 28; + unsigned long phy_addr = addr & 0xFFFFFFF; struct hw_device *dev = device_table[id]; struct hw_class *class_ptr = dev->class_ptr; - class_ptr->write (dev, phy_addr, val); + class_ptr->write(dev, phy_addr, val); } - - -absolute_address_t -to_absolute (unsigned long cpuaddr) +absolute_address_t to_absolute (unsigned long cpuaddr) { struct bus_map *map = find_map (cpuaddr); struct hw_device *dev = find_device (cpuaddr, map->devid); @@ -306,7 +288,6 @@ void dump_machine (void) unsigned int prev_offset; unsigned int prev_flags; unsigned int dot_dot = 0; - unsigned int n; /* machine */ printf("Machine: %s\n", machine->name); @@ -350,7 +331,6 @@ void dump_machine (void) } } - /********************************************************** * Simple fault handler **********************************************************/ @@ -368,7 +348,6 @@ void fault (unsigned int addr, unsigned char type) } } - /**********************************************************/ void null_reset (struct hw_device *dev) @@ -398,7 +377,6 @@ struct hw_device *null_create (void) return device_attach (&null_class, 0, NULL); } - /**********************************************************/ void ram_reset (struct hw_device *dev) @@ -444,7 +422,6 @@ struct hw_class rom_class = .write = ram_write, }; - struct hw_device *rom_create (const char *filename, unsigned int maxsize) { FILE *fp; @@ -453,7 +430,7 @@ struct hw_device *rom_create (const char *filename, unsigned int maxsize) char *buf; if (filename) - { + { fp = file_open (NULL, filename, "rb"); if (!fp) return NULL; @@ -522,7 +499,6 @@ struct hw_device *console_create (void) /**********************************************************/ - U8 mmu_regs[MMU_PAGECOUNT][MMU_PAGEREGS]; U8 mmu_read (struct hw_device *dev, unsigned long addr) @@ -581,7 +557,7 @@ void mmu_reset_complete (struct hw_device *dev) { map = &busmaps[4 + page * (MMU_PAGESIZE / BUS_MAP_SIZE)]; mmu_regs[page][0] = map->devid; - mmu_regs[page][1] = map->offset / MMU_PAGESIZE; + mmu_regs[page][1] = (U8) (map->offset / MMU_PAGESIZE); mmu_regs[page][2] = map->flags & MAP_READWRITE; /* printf ("%02X %02X %02X\n", map->devid, map->offset / MMU_PAGESIZE, @@ -589,7 +565,6 @@ void mmu_reset_complete (struct hw_device *dev) } } - struct hw_class mmu_class = { .name = "mmu", @@ -604,7 +579,6 @@ struct hw_device *mmu_create (void) return device_attach (&mmu_class, BUS_MAP_SIZE, NULL); } - /**********************************************************/ void machine_update (void) @@ -629,7 +603,6 @@ int machine_match (const char *machine_name, const char *boot_rom_file, struct m return 0; } - void machine_init (const char *machine_name, const char *boot_rom_file) { extern struct machine simple_machine; diff --git a/mmu.c b/mmu.c index 973ff65..6d0054c 100644 --- a/mmu.c +++ b/mmu.c @@ -1,4 +1,3 @@ - #include #include "machine.h" @@ -101,7 +100,7 @@ struct hw_class small_mmu_class = .write = small_mmu_write, }; -struct hw_device *small_mmu_create (struct hw_device *realdev) +struct hw_device* small_mmu_create (struct hw_device *realdev) { struct small_mmu *mmu = malloc (sizeof (struct small_mmu)); mmu->realdev = realdev; diff --git a/monitor.c b/monitor.c index 96ab702..38bf5ea 100644 --- a/monitor.c +++ b/monitor.c @@ -19,13 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #include "6809.h" #include "monitor.h" #include #include - /* The function call stack */ struct function_call fctab[MAX_FUNCTION_CALLS]; @@ -39,7 +37,6 @@ int monitor_on = 0; int dump_every_insn = 0; - enum addr_mode { _illegal, _implied, _imm_byte, _imm_word, _direct, _extended, @@ -888,11 +885,9 @@ char *off4[] = { "-8", "-7", "-6", "-5", "-4", "-3", "-2", "-1" }; - /* Disassemble the current instruction. Returns the number of bytes that compose it. */ -int -dasm (char *buf, absolute_address_t opc) +int dasm (char *buf, absolute_address_t opc) { UINT8 op, am; char *op_str; @@ -900,17 +895,17 @@ dasm (char *buf, absolute_address_t opc) char R; int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */ - op = fetch8 (); + op = fetch8(); if (op == 0x10) { - op = fetch8 (); + op = fetch8(); am = codes10[op].mode; op = codes10[op].code; } else if (op == 0x11) { - op = fetch8 (); + op = fetch8(); am = codes11[op].mode; op = codes11[op].code; } @@ -1076,8 +1071,7 @@ dasm (char *buf, absolute_address_t opc) return pc - opc; } -int -sizeof_file (FILE * file) +int sizeof_file(FILE * file) { int size; @@ -1088,7 +1082,6 @@ sizeof_file (FILE * file) return size; } - int load_map_file (const char *name) { @@ -1111,7 +1104,7 @@ load_map_file (const char *name) if (s) { sprintf (s+1, "map"); - fp = file_open (NULL, map_filename, "r"); + fp = file_open(NULL, map_filename, "r"); } if (!fp) @@ -1131,7 +1124,7 @@ load_map_file (const char *name) value_ptr = buf; if (!strncmp (value_ptr, "page", 4)) { - unsigned char page = strtoul (value_ptr+4, NULL, 10); + unsigned char page = (unsigned char) strtoul(value_ptr+4, NULL, 10); if (!strcmp (machine->name, "wpc")) wpc_set_rom_page (page); sym = NULL; @@ -1144,7 +1137,7 @@ load_map_file (const char *name) while (*value_ptr == ' ') value_ptr++; - value = strtoul (value_ptr, &id_ptr, 16); + value = (target_addr_t) strtoul(value_ptr, &id_ptr, 16); if (id_ptr == value_ptr) continue; @@ -1167,17 +1160,15 @@ load_map_file (const char *name) return 0; } - /* Auto-detect image file type and load it. For this to work, the machine must already be initialized. */ -int -load_image (const char *name) +int load_image (const char *name) { int count, addr, type; FILE *fp; - fp = file_open (NULL, name, "r"); + fp = file_open(NULL, name, "r"); if (fp == NULL) { @@ -1202,9 +1193,7 @@ load_image (const char *name) } } - -int -load_hex (FILE *fp) +int load_hex (FILE *fp) { int count, addr, type, data, checksum; int done = 1; @@ -1268,9 +1257,7 @@ load_hex (FILE *fp) return 0; } - -int -load_s19 (FILE *fp) +int load_s19 (FILE *fp) { int count, addr, type, data, checksum; int done = 1; @@ -1333,9 +1320,7 @@ load_s19 (FILE *fp) return 0; } - -void -monitor_call (unsigned int flags) +void monitor_call (unsigned int flags) { #ifdef CALL_STACK if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1]) @@ -1354,9 +1339,7 @@ monitor_call (unsigned int flags) #endif } - -void -monitor_return (void) +void monitor_return (void) { #ifdef CALL_STACK if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1]) @@ -1376,9 +1359,7 @@ monitor_return (void) #endif } - -const char * -absolute_addr_name (absolute_address_t addr) +const char* absolute_addr_name (absolute_address_t addr) { static char buf[256], *bufptr; const char *name; @@ -1394,9 +1375,7 @@ absolute_addr_name (absolute_address_t addr) return buf; } - -const char * -monitor_addr_name (target_addr_t target_addr) +const char* monitor_addr_name (target_addr_t target_addr) { static char buf[256], *bufptr; const char *name; @@ -1413,22 +1392,16 @@ monitor_addr_name (target_addr_t target_addr) return buf; } - -static void -monitor_signal (int sigtype) +static void monitor_signal (int sigtype) { (void) sigtype; putchar ('\n'); monitor_on = 1; } - -void -monitor_init (void) +void monitor_init (void) { - int tmp; extern int debug_enabled; - target_addr_t a; fctab[0].entry_point = read16 (0xfffe); memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs)); @@ -1439,9 +1412,7 @@ monitor_init (void) signal (SIGINT, monitor_signal); } - -int -check_break (void) +int check_break (void) { if (dump_every_insn) print_current_insn (); @@ -1452,9 +1423,7 @@ check_break (void) return 0; } - -void -monitor_backtrace (void) +void monitor_backtrace (void) { struct function_call *fc = current_function_call; while (fc >= &fctab[0]) { @@ -1463,8 +1432,7 @@ monitor_backtrace (void) } } -int -monitor6809 (void) +int monitor6809 (void) { int rc; diff --git a/serial.c b/serial.c index ea0d999..7f56d8d 100644 --- a/serial.c +++ b/serial.c @@ -127,8 +127,7 @@ struct hw_class serial_class = extern U8 null_read (struct hw_device *dev, unsigned long addr); - -struct hw_device *serial_create (void) +struct hw_device* serial_create (void) { struct serial_port *port = malloc (sizeof (struct serial_port)); port->fin = STDIN_FILENO; @@ -136,10 +135,9 @@ struct hw_device *serial_create (void) return device_attach (&serial_class, 4, port); } -struct hw_device *hostfile_create (const char *filename, int flags) +struct hw_device* hostfile_create (const char *filename, int flags) { struct serial_port *port = malloc (sizeof (struct serial_port)); - port->fin = port->fout = open (filename, O_CREAT | flags, S_IRUSR | S_IWUSR); + port->fin = port->fout = open(filename, O_CREAT | flags, S_IRUSR | S_IWUSR); return device_attach (&serial_class, 4, port); } - diff --git a/timer.c b/timer.c index 865be73..db6a09a 100644 --- a/timer.c +++ b/timer.c @@ -170,7 +170,7 @@ struct hw_class oscillator_class = .update = hwtimer_update, }; -struct hw_device *oscillator_create (struct hw_device *int_dev, unsigned int int_line) +struct hw_device *oscillator_create(struct hw_device *int_dev, unsigned int int_line) { struct hwtimer *timer = malloc (sizeof (struct hwtimer)); timer->reload = 2048; /* cycles per pulse */ diff --git a/wpc.c b/wpc.c index 02f81c2..e6f94a8 100644 --- a/wpc.c +++ b/wpc.c @@ -286,8 +286,7 @@ void wpc_dmd_set_visible (U8 val) { char *p; struct wpc_message msg; - int rc; - int i, n; + int i; static unsigned long last_firq_time = 0; unsigned long now; static int no_change_count = 0; @@ -333,7 +332,7 @@ void wpc_dmd_set_visible (U8 val) wpc_msg_init (CODE_DMD_PAGE, &msg); for (i=0; i < 3; i++) { - p = wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512; + p = (U8*) wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512; msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i]; memcpy (&msg.u.dmdpage.phases[i].data, p, 512); } @@ -498,7 +497,6 @@ void wpc_update_ram (void) WPC_RAM_SIZE - size_writable, MAP_READABLE); } - void wpc_set_rom_page (unsigned char val) { bus_map (WPC_PAGED_REGION, 2, val * WPC_PAGED_SIZE, WPC_PAGED_SIZE, MAP_READABLE); @@ -665,8 +663,6 @@ void io_sym_add (const char *name, unsigned long cpuaddr) void wpc_init (const char *boot_rom_file) { struct hw_device *dev; - int rc; - struct sockaddr_in myaddr; device_define ( dev = wpc_asic_create (), 0, WPC_ASIC_BASE, WPC_PAGED_REGION - WPC_ASIC_BASE, MAP_READWRITE); From b3d829bf69738d9bda1f8a3c317c1aa138e7a8d9 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 3 May 2015 17:46:30 +0100 Subject: [PATCH 22/71] More whitespace tweaks for consistency. Haven't started on indent yet. Updates to command.c from Erik, so that byte stream is printed for list and trace-dump in addition to disassembly. --- command.c | 18 ++++-------------- monitor.c | 31 +++++++++++++++---------------- 2 files changed, 19 insertions(+), 30 deletions(-) diff --git a/command.c b/command.c index 858bcaa..9debe6e 100644 --- a/command.c +++ b/command.c @@ -889,12 +889,9 @@ void cmd_list (void) lastaddr = lastpc = addr; } - for (n = 0; n < 10; n++) + for (n = 0; n < 16; n++) { - print_addr (addr); - printf (" : "); - addr += print_insn (addr); - putchar ('\n'); + addr += print_insn_long(addr); } lastaddr = addr; @@ -1039,10 +1036,7 @@ void cmd_trace_dump (void) absolute_address_t addr = to_absolute (pc); //const char *name = sym_lookup (&program_symtab, addr); //printf ("%04X ", pc); - print_addr (addr); - putchar (':'); - print_insn (addr); - putchar ('\n'); + print_insn_long(addr); //putchar (name ? '\n' : ' '); off = (off + 1) % MAX_TRACE; } while (off != trace_offset); @@ -1221,11 +1215,7 @@ int print_insn_long (absolute_address_t addr) void print_current_insn (void) { - absolute_address_t addr = to_absolute (get_pc ()); - print_addr (addr); - printf (" : "); - print_insn (addr); - putchar ('\n'); + print_insn_long(to_absolute(get_pc())); } int command_exec (FILE *infile) diff --git a/monitor.c b/monitor.c index 38bf5ea..44da172 100644 --- a/monitor.c +++ b/monitor.c @@ -1124,7 +1124,7 @@ load_map_file (const char *name) value_ptr = buf; if (!strncmp (value_ptr, "page", 4)) { - unsigned char page = (unsigned char) strtoul(value_ptr+4, NULL, 10); + unsigned char page = (unsigned char) strtoul(value_ptr+4, NULL, 10); if (!strcmp (machine->name, "wpc")) wpc_set_rom_page (page); sym = NULL; @@ -1169,10 +1169,9 @@ int load_image (const char *name) FILE *fp; fp = file_open(NULL, name, "r"); - if (fp == NULL) { - printf ("failed to open image file %s.\n", name); + printf("failed to open image file %s.\n", name); return 1; } @@ -1215,39 +1214,39 @@ int load_hex (FILE *fp) case 0: for (; count != 0; count--, addr++, checksum += data) { - if (fscanf (fp, "%2x", &data)) + if (fscanf(fp, "%2x", &data)) { - write8 (addr, (UINT8) data); + write8(addr, (UINT8) data); } else { - printf ("line %d: hex record data inconsistent with count field.\n", line); + printf("line %d: hex record data inconsistent with count field.\n", line); break; } } checksum = (-checksum) & 0xff; - if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) + if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) { - printf ("line %d: hex record checksum missing or invalid.\n", line); + printf("line %d: hex record checksum missing or invalid.\n", line); done = 0; break; } - fscanf (fp, "%*[\r\n]"); /* skip any form of line ending */ + fscanf(fp, "%*[\r\n]"); /* skip any form of line ending */ break; case 1: checksum = (-checksum) & 0xff; - if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) - printf ("line %d: hex record checksum missing or invalid.\n", line); + if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) + printf("line %d: hex record checksum missing or invalid.\n", line); done = 0; break; case 2: default: - printf ("line %d: not supported hex type %d.\n", line, type); + printf("line %d: not supported hex type %d.\n", line, type); done = 0; break; } @@ -1257,7 +1256,7 @@ int load_hex (FILE *fp) return 0; } -int load_s19 (FILE *fp) +int load_s19(FILE *fp) { int count, addr, type, data, checksum; int done = 1; @@ -1267,9 +1266,9 @@ int load_s19 (FILE *fp) { line++; - if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) != 3) + if (fscanf(fp, "S%1x%2x%4x", &type, &count, &addr) != 3) { - printf ("line %d: invalid S record information.\n", line); + printf("line %d: invalid S record information.\n", line); break; } @@ -1316,7 +1315,7 @@ int load_s19 (FILE *fp) } } - (void) fclose (fp); + (void) fclose(fp); return 0; } From de59e1401ae5bc3e87ba238b472e5a78305372d4 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 31 May 2015 20:17:15 +0100 Subject: [PATCH 23/71] formatting tidy-ups --- command.c | 7 ++----- monitor.c | 17 ++++++++--------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/command.c b/command.c index 9debe6e..70bb2c8 100644 --- a/command.c +++ b/command.c @@ -96,7 +96,7 @@ void print_addr (absolute_address_t addr) name = sym_lookup (&program_symtab, addr); if (name) - printf (" <%-16.16s>", name); + printf (" %-18.18s", name); else printf ("%-20.20s", ""); } @@ -588,7 +588,7 @@ void do_examine (void) break; case 'i': /* instruction */ - examine_addr += print_insn (examine_addr); + examine_addr += print_insn (examine_addr); break; default: @@ -1034,10 +1034,7 @@ void cmd_trace_dump (void) do { target_addr_t pc = trace_buffer[off]; absolute_address_t addr = to_absolute (pc); - //const char *name = sym_lookup (&program_symtab, addr); - //printf ("%04X ", pc); print_insn_long(addr); - //putchar (name ? '\n' : ' '); off = (off + 1) % MAX_TRACE; } while (off != trace_offset); fflush (stdout); diff --git a/monitor.c b/monitor.c index 44da172..3071ace 100644 --- a/monitor.c +++ b/monitor.c @@ -1011,13 +1011,13 @@ int dasm (char *buf, absolute_address_t opc) sprintf (buf, "[D,%c]", R); break; case 0x1C: - sprintf (buf, "[$%02X,PC]", fetch8 ()); + sprintf (buf, "[$%02X,PC]", fetch8()); break; case 0x1D: - sprintf (buf, "[$%04X,PC]", fetch16 ()); + sprintf (buf, "[$%04X,PC]", fetch16()); break; case 0x1F: - sprintf (buf, "[%s]", monitor_addr_name (fetch16 ())); + sprintf (buf, "[%s]", monitor_addr_name (fetch16())); break; default: sprintf (buf, "???"); @@ -1031,7 +1031,7 @@ int dasm (char *buf, absolute_address_t opc) break; case _rel_word: - sprintf (buf, "%s", absolute_addr_name (fetch16 () + pc)); + sprintf (buf, "%s", absolute_addr_name (fetch16() + pc)); break; case _reg_post: @@ -1082,8 +1082,7 @@ int sizeof_file(FILE * file) return size; } -int -load_map_file (const char *name) +int load_map_file (const char *name) { FILE *fp; char map_filename[256]; @@ -1369,7 +1368,7 @@ const char* absolute_addr_name (absolute_address_t addr) name = sym_lookup (&program_symtab, addr); if (name) - bufptr += sprintf (bufptr, " <%-16.16s>", name); + sprintf (bufptr, " <%-16.16s>", name); return buf; } @@ -1382,11 +1381,11 @@ const char* monitor_addr_name (target_addr_t target_addr) bufptr = buf; - bufptr += sprintf (bufptr, "0x%04X", target_addr); + bufptr += sprintf (bufptr, "$%04X", target_addr); name = sym_lookup (&program_symtab, addr); if (name) - bufptr += sprintf (bufptr, " <%s>", name); + sprintf (bufptr, " <%s>", name); return buf; } From 1e82c8cb8de8f9f98aeaa1e8f74ae6294574bf80 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 31 May 2015 20:17:36 +0100 Subject: [PATCH 24/71] Add virtual SD card device driver to multicomp - allows FLEX and CUBIX to boot in emulation. --- miscsbc.c | 476 ++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 424 insertions(+), 52 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 4f595f1..3f083e0 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -1,5 +1,6 @@ #include #include "machine.h" +#include // for symtab stuff? #include "6809.h" @@ -7,6 +8,23 @@ int smii_i_avail = 1; int smii_o_busy = 0; +// for multicomp09 sdmapper +char mc_protect = 0x00; +char mc_romdis = 0x00; +char mc_mapper = 0x76; +unsigned char mc_sdlba2; // because we're doing maths on them +unsigned char mc_sdlba1; +unsigned char mc_sdlba0; +char mc_data[512]; +int mc_addr; +int mc_state; +int mc_poll; +int mc_dindex; +FILE *sd_file; +// [NAC HACK 2015May07] to allow remap of io. Really nasty hack. +struct hw_device *mc_rom, *mc_ram, *mc_iodev; + +FILE *batch_file; /******************************************************************** * The Scroungemaster II machine, a platform @@ -22,18 +40,21 @@ int smii_o_busy = 0; U8 smii_console_read (struct hw_device *dev, unsigned long addr) { unsigned char ch; - switch (addr) - { + switch (addr) { case 0x02: // SCCACMD // on output make it seem busy for several polls smii_o_busy = smii_o_busy == 0 ? 0 : (smii_o_busy + 1)%4; // printf("02 smii_o_busy = %d return 0x%02x\n",smii_o_busy,(smii_i_avail & 1) | (smii_o_busy == 0 ? 4 : 0)); return (smii_i_avail & 1) | (smii_o_busy == 0 ? 4 : 0); case 0x03: // SCCADTA - ch = getchar(); + if (batch_file && fread( &ch, 1, 1, batch_file)) { + } + else { + ch = getchar(); + } // key conversions to make keyboard look DOS-like if (ch == 127) ch = 8; //backspace - if (ch == 10) ch = 13; //cr + if (ch == 10) ch = 13; //cr return ch; default: printf("In smii_console_read with addr=0x%08x\n", addr); @@ -44,20 +65,19 @@ U8 smii_console_read (struct hw_device *dev, unsigned long addr) void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) { - switch (addr) - { - case 0x00: - case 0x02: - // UART setup. Not emulated; just ignore it. - break; - case 0x03: // SCCADTA - if(smii_o_busy != 0) printf("Oops! Write to busy UART\n"); - smii_o_busy = 1; - putchar(val); - break; - default: - printf("In smii_console_write with addr=0x%08x val=0x%02x\n",addr, val); - } + switch (addr) { + case 0x00: + case 0x02: + // UART setup. Not emulated; just ignore it. + break; + case 0x03: // SCCADTA + if (smii_o_busy != 0) printf("Oops! Write to busy UART\n"); + smii_o_busy = 1; + putchar(val); + break; + default: + printf("In smii_console_write with addr=0x%08x val=0x%02x\n",addr, val); + } } @@ -140,6 +160,13 @@ void smii_init (const char *boot_rom_file) device_define ( smii_console, 0, 0x7C00, BUS_MAP_SIZE, MAP_READWRITE ); + + + + /* If a file smii.bat exists, supply input from it until + it's exhausted. + */ + batch_file = file_open(NULL, "smii.bat", "rb"); } @@ -154,24 +181,29 @@ struct machine smii_machine = /******************************************************************** * The Multicomp 6809 machine, a platform for Dragon BASIC. - * This version has 1 serial port, 56K RAM and 8K ROM + * This version has 1 serial port, 56K RAM and 8K ROM, SDCARD if * The serial port is in a "hole" at 0xFFD0/0xFFD1 * See: * Grant Searle http://searle.hostei.com/grant/Multicomp/index.html * ********************************************************************/ -// console input is blocking. +/* UART-style console. Console input is blocking (but should not be) + */ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) { unsigned char ch; - switch (addr) - { + switch (addr) { case 00: // status bit return 0xff; case 01: - ch = getchar(); + if (batch_file && fread( &ch, 1, 1, batch_file)) { + } + else { + ch = getchar(); + } + // key conversions to make keyboard look DOS-like if (ch == 127) return 8; // rubout->backspace if (ch == 10) return 13; // LF->CR return ch; @@ -183,50 +215,360 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 val) { - switch (addr) - { - case 00: - printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); - break; + switch (addr) { + case 0: + printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); + break; + + case 1: + //if ((val != 0x0d) && (val != 0x20) && (val != 0x0a) && (val < '0')) { + // printf("Char 0x%02x", val); + //} + putchar(val); + break; + + default: + printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); + } +} + +/* SDCARD and memory mapper + FFDF SDCARD MAPPER wo remaps 2 RAM windows + FFDE SDCARD ROMDIS wo bit 0 disables ROM when 1 + FFDD SDCARD PROTECT wo write protect in resolution of 8KByte + FFDC SDCARD SDLBA2 wo + FFDB SDCARD SDLBA1 wo + FFDA SDCARD SDLBA0 wo + FFD9 SDCARD SDCONTROL/SDSTATUS + FFD8 SDCARD SDDATA r/w + + Access using 32-bit address in which the low 9 bits are 0 (each sector is 512 bytes). The + address is set using the SDLBA registers like this: + + 31 30 29 28.27 26 25 24.23 22 21 20.19 18 17 16.15 14 13 12.11 10 09 08.07 06 05 04.03 02 01 00 + +------- SDLBA2 -----+------- SDLBA1 --------+------- SDLBA0 --------+ 0 0 0 0 0 0 0 0 0 + + SDSTATUS (RO) + b7 Write Data Byte can be accepted + b6 Read Data Byte available + b5 Block Busy + b4 Init Busy + b3 Unused. Read 0 + b2 Unused. Read 0 + b1 Unused. Read 0 + b0 Unused. Read 0 + + SDCONTROL (WO) + b7:0 0x00 Read block + 0x01 Write block + + + mc_state = 0 no card. Will never complete initialisation + 1 initialising. Will initialise after 16 polls + of status register (hokey but works!) + 2 idle. Read and Write commands allowed. + 3 in read. Takes 3 polls for each byte becomes + available. + 4 in write. Takes 3 polls before each byte + can be accepted. + error if too much data written or read or if command while + not idle. + */ +// Use values of mc_protect, mc_romdis, mc_mapper to set up address mappings. +void sdmapper_remap() +{ + int i; + //[NAC HACK 2015May06] Yeuch. Horrible how I have had to hardwire the device numbers. + //overall, it would be better if I could pick them in the first place. + + + // addr dev offset len flags + + // 0x0000-0x1FFF always direct mapped to RAM + bus_map(0x0000, 1, 0x0000, 0x2000, (mc_protect & 1) ? MAP_READABLE : MAP_READWRITE); + + // 0x2000-0x3FFF always direct mapped to RAM + bus_map(0x2000, 1, 0x2000, 0x2000, (mc_protect & 2) ? MAP_READABLE : MAP_READWRITE); + + // 0x4000-0x5FFF always direct mapped to RAM + bus_map(0x4000, 1, 0x4000, 0x2000, (mc_protect & 4) ? MAP_READABLE : MAP_READWRITE); + + // 0x6000-0x7FFF always direct mapped to RAM + bus_map(0x6000, 1, 0x6000, 0x2000, (mc_protect & 8) ? MAP_READABLE : MAP_READWRITE); + + // 0x8000-0x9FFF always direct mapped to RAM + bus_map(0x8000, 1, 0x8000, 0x2000, (mc_protect & 16) ? MAP_READABLE : MAP_READWRITE); + + // 0xA000-0xBFFF always direct mapped to RAM + bus_map(0xA000, 1, 0xA000, 0x2000, (mc_protect & 32) ? MAP_READABLE : MAP_READWRITE); + + // 0xC000-0xDFFF remappable RAM + bus_map(0xC000, 1, (mc_mapper & 0xf)<<13, 0x2000, (mc_protect & 64) ? MAP_READABLE : MAP_READWRITE); + + // 0xE000-0xFFFF ROM or remappable RAM + if (mc_romdis & 1) { + // ROM disabled; map RAM + bus_map(0xE000, 1, (mc_mapper & 0xf0)<<9, 0x2000, (mc_protect & 128) ? MAP_READABLE : MAP_READWRITE); + } + else { + // ROM + bus_map(0xE000, 2, 0x0000, 0x2000, MAP_READABLE); // ROM + } + + // need to do IOEXPAND last because it overwrites a section within + // a larger window. + bus_map(0xFF80, 5, 0x0000, 128, MAP_READWRITE); // IOEXPAND + + // need to do this again for the windows that map back + // to underlying ROM.. because it may now be underlying RAM + for (i=0; i<16; i++) { + if ((i!=10) && (i!=11)) { + // Map to underlying memory. Read will have an address of 0x0-0xf + // so we need to apply an offset to get it to the + // right place. The offset is from the start of the + // romdev and has nothing to do with the actual + // bus address of the location. + // Access permission inherited from underlying + // device, which is exactly what I want. + if (mc_romdis) { + // RAM. Offset is a function of paging register + ioexpand_attach(mc_iodev, i, ((mc_mapper & 0xf0)<<9) + 0x1F80 + (i*8), mc_ram); + } + else { + // ROM + ioexpand_attach(mc_iodev, i, 0x1F80 + (i*8), mc_rom); + } + } + } +} - case 01: - putchar(val); - break; - default: - printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); +U8 sdmapper_read (struct hw_device *dev, unsigned long addr) +{ + unsigned char ch; + //printf("INFO In sdmapper_read with addr=0x%08x, mc_state=%d, mc_poll=%d\n", addr, mc_state, mc_poll); + switch (addr) { + case 0: // SDDATA + switch (mc_state) { + case 0: case 1: case 2: + return 0xff; + case 3: // in read + if (mc_poll == 3) { + mc_poll = 0; + if (mc_dindex == 511) { + mc_state = 2; // final read then back to idle + } + if (mc_dindex < 512) { + return mc_data[mc_dindex++]; + } + else { + printf("ERROR attempt to read too much data from sd block\n"); + return 0xff; + } + } + else { + printf("ERROR attempt to read sd block when data not yet available\n"); + return 0xff; + } + case 4: // in write + printf("ERROR attempt to read sd data during write command\n"); + return 0xff; } + break; // unreachable + case 1: // SDCONTROL + switch (mc_state) + { + case 0: // busy and always will remain so + return 0x90; + case 1: // count polls and initialise + mc_poll++; + if (mc_poll == 16) + mc_state = 2; + return 0x90; + case 2: // idle. + return 0x80; + case 3: // in read + if (mc_poll < 3) + mc_poll++; + if (mc_poll == 3) + return 0xe0; // data available + else + return 0xa0; // still waiting TODO maybe 20 + case 4: // in write + if (mc_poll < 3) + mc_poll++; + if (mc_poll == 3) + return 0xa0; // space available + else + return 0x20; // still waiting + } + break; // unreachable + default: + printf("INFO In sdmapper_read with addr=0x%08x\n", addr); + return 0x42; + } +} + +// TODO expand RAM and implement mapper, protect and rom disable +void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) +{ + int retvar; + //printf("INFO In sdmapper_write with addr=0x%08x, mc_state=%d mc_poll=%d mc_dindex=%d\n", addr, mc_state, mc_poll, mc_dindex); + switch (addr) { + case 0: // SDDATA + switch (mc_state) { + case 0: case 1: case 2: case 3: + printf("ERROR attempt to write to sd data during sd block read\n"); + break; + case 4: // in write + if (mc_poll == 3) { + mc_poll = 0; + if (mc_dindex < 512) { + mc_data[mc_dindex++] = val; + if (mc_dindex == 512) { + // commit the data + if (fseek(sd_file, mc_addr, SEEK_SET)) { + printf("ERROR seek to sd offset address 0x%x for write failed\n", mc_addr); + } + else { + retvar = fwrite(mc_data, 512, 1, sd_file); + assert(retvar != -1); + } + mc_state = 2; // back to idle. + } + } + else { + printf("ERROR attempt to write too much data to sd block\n"); + } + } + else { + printf("ERROR attempt to write sd data when space not yet available\n"); + } + break; + } + break; + case 1: // SDCONTROL + switch (mc_state) { + case 0: + printf("ERROR attempt to write to sd control but no sd image file\n"); + break; + case 1: + printf("ERROR attempt to write to sd control but still initialising\n"); + break; + case 2: + // form address + mc_addr = ((0x7f & mc_sdlba2) << 25) | (mc_sdlba1 << 17) | (mc_sdlba0 << 9); + mc_poll = 0; + switch (val) { + case 0: // read command + mc_dindex = 0; + mc_state = 3; + if (fseek(sd_file, mc_addr, SEEK_SET)) { + printf("ERROR seek to sd offset address 0x%x for read failed\n", mc_addr); + for (mc_dindex = 0; mc_dindex < 512; mc_dindex++) { + mc_data[mc_dindex] = 0xff; + mc_dindex = 0; + } + } + else { + retvar = fread(mc_data, 512, 1, sd_file); + assert(retvar != -1); + } + break; + case 1: // write command + mc_dindex = 0; + mc_state = 4; + break; + default: + printf("ERROR unknown sd command 0x%02x\n", val); + break; + } + break; + case 3: + printf("ERROR attempt to write to sd control during sd block read\n"); + break; + case 4: + printf("ERROR attempt to write to sd control during sd block write\n"); + break; + } + case 2: // SDLBA0 + mc_sdlba0 = val; + break; + case 3: // SDLBA1 + mc_sdlba1 = val; + break; + case 4: // SDLBA2 + mc_sdlba2 = val; + break; + case 5: // PROTECT + mc_protect = val; + sdmapper_remap(); + break; + case 6: // ROMDIS + mc_romdis = val; + sdmapper_remap(); + break; + case 7: // MAPPER + mc_mapper = val; + sdmapper_remap(); + break; + } +} + +void sdmapper_reset (struct hw_device *dev) +{ +} + +struct hw_class sdmapper_class = +{ + .name = "sdmapper", + .readonly = 0, + .reset = sdmapper_reset, + .read = sdmapper_read, + .write = sdmapper_write, +}; + +struct hw_device* sdmapper_create (void) +{ + return device_attach (&sdmapper_class, BUS_MAP_SIZE, NULL); } +// [NAC HACK 2015May05] is it legal to have more than one instance of anything? +// eg 2 RAMs? I assumed it was but now I realise IT IS NOT! Yeuch. +// I assume the same restriction also applies to ROMs and RAMs void multicomp09_init (const char *boot_rom_file) { - struct hw_device *multicomp09_console; - struct hw_device *iodev; - struct hw_device *romdev; + struct hw_device* multicomp09_console; + struct hw_device* multicomp09_sdmapper; + struct hw_device* iodev; + struct hw_device* ramdev; + struct hw_device* romdev; int i; - /* RAM from 0 to DFFF */ - device_define ( ram_create (0xE000), 0, - 0x0000, 0xE000, MAP_READWRITE ); - - // use the defn below when working on the NXM core-dump bug. - // device_define ( ram_create (0x8000), 0, - // 0x0000, 0x8000, MAP_READWRITE ); + /* RAM is 128Kbytes. Low 6, 8K chunks are always mapped into + the address space. The upper 2, 8K chunks (CD, EF) are + windows into any of the 16, 8K chunks via the mc_mapping + register. + */ + ramdev = ram_create(0x20000); - /* ROM from E000 to FFFF */ + /* ROM is 8Kbytes. Usually sits from E000 to FFFF but can be disabled + by writing 1 to mc_romdis. + */ romdev = rom_create (boot_rom_file, 0x2000); - device_define (romdev, 0, - 0xE000, 0x2000, MAP_READABLE); - /* I/O console */ + /* I/O - UART */ multicomp09_console = console_create(); multicomp09_console->class_ptr->read = multicomp09_console_read; multicomp09_console->class_ptr->write = multicomp09_console_write; - /* I/O console at FFD0/FFD1 + /* I/O - sdmapper */ + multicomp09_sdmapper = sdmapper_create(); + + /* I/O devices at FFD0/FFDF Use an ioexpand device at 0xFF80-0xFFFF. - This overlays the ROM mapping and creating it after + This overlays the ROM mapping and creating it *after* the ROM overwrites the ROM's mapping. The ioexpand provides 16 slots of 8 bytes Use some for the IO, map the others back to the ROM @@ -234,13 +576,20 @@ void multicomp09_init (const char *boot_rom_file) in order to provide the exception vectors. */ iodev = ioexpand_create(); - device_define(iodev, 0, 0xFF80, 128, MAP_READWRITE); + for (i=0; i<16; i++) { if (i==10) { - // 0xFFD0-0xFFD7 + // 0xFFD0-0xFFD7 -- VDU and UART ioexpand_attach(iodev, i, 0, multicomp09_console); } + else if (i==11) { + // 0xFFD8-0xFFDF -- SDCARD and MemMapper + ioexpand_attach(iodev, i, 0, multicomp09_sdmapper); + } else { + //[NAC HACK 2015May07] done in sdmapper_remap in a moment + // so no real reason to do it here.. + // Map to ROM. Read will have an address of 0x0-0xf // so we need to apply an offset to get it to the // right place. The offset is from the start of the @@ -249,10 +598,33 @@ void multicomp09_init (const char *boot_rom_file) ioexpand_attach(iodev, i, 0x1F80 + (i*8), romdev); } } -} + //[NAC HACK 2015May07] need a nicer way than this! + mc_rom = romdev; + mc_ram = ramdev; + mc_iodev = iodev; + /* Now map all the devices into he address space, in accordance + with the settings of the memory mapper. + */ + sdmapper_remap(); + /* If a file multicomp09.bat exists, supply input from it until + it's exhausted. + */ + batch_file = file_open(NULL, "multicomp09.bat", "rb"); + + /* If a file multicomp09_sd.img exists, open it. sdcard will + only transition to initialised state if file exists + */ + sd_file = file_open(NULL, "multicomp09_sd.img", "r+b"); + mc_poll = 0; + if (sd_file) + mc_state = 1; + else + mc_state = 0; +} + struct machine multicomp09_machine = { From e7e8fbee07359c1d691e3df140dff1f19b1d225d Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Mon, 8 Jun 2015 15:32:22 +0100 Subject: [PATCH 25/71] Change register dump format to use upper-case letters in hex digits for consistency. --- 6809.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/6809.c b/6809.c index 0dad214..8f70380 100644 --- a/6809.c +++ b/6809.c @@ -3041,13 +3041,13 @@ void print_regs (void) if (get_cc() & F_FLAG) flags[6] = 'F'; if (get_cc() & E_FLAG) flags[7] = 'E'; - printf (" X: 0x%04x [X]: 0x%04x Y: 0x%04x [Y]: 0x%04x ", + printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", get_x(), read16(get_x()), get_y(), read16(get_y()) ); - printf ("PC: 0x%04x [PC]: 0x%04x\n", + printf ("PC: 0x%04X [PC]: 0x%04X\n", get_pc(), read16(get_pc()) ); - printf (" U: 0x%04x [U]: 0x%04x S: 0x%04x [S]: 0x%04x ", + printf (" U: 0x%04X [U]: 0x%04X S: 0x%04X [S]: 0x%04X ", get_u(), read16(get_u()), get_s(), read16(get_s()) ); - printf ("DP: 0x%02x\n", get_dp() ); - printf (" A: 0x%02x B: 0x%02x [D]: 0x%04x CC: %s\n", + printf ("DP: 0x%02X\n", get_dp() ); + printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", get_a(), get_b(), read16(get_d()), flags ); } From ae5dca4eeb36864af56602b9fce5f69ffba78e7a Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 23 Jun 2015 15:51:19 +0100 Subject: [PATCH 26/71] sync up latest files. Some are work-in-progress. --- Makefile.in | 19 +- config.h.in | 3 + configure | 4831 +++++++++++++++++++-------------------------------- machine.c | 61 +- monitor.c | 1 + 5 files changed, 1834 insertions(+), 3081 deletions(-) diff --git a/Makefile.in b/Makefile.in index 1de4b0b..891d918 100644 --- a/Makefile.in +++ b/Makefile.in @@ -35,7 +35,6 @@ POST_INSTALL = : NORMAL_UNINSTALL = : PRE_UNINSTALL = : POST_UNINSTALL = : -LIBOBJDIR = bin_PROGRAMS = m6809-run$(EXEEXT) subdir = . DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \ @@ -54,10 +53,11 @@ am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(bindir)" binPROGRAMS_INSTALL = $(INSTALL_PROGRAM) PROGRAMS = $(bin_PROGRAMS) am_m6809_run_OBJECTS = 6809.$(OBJEXT) main.$(OBJEXT) monitor.$(OBJEXT) \ - machine.$(OBJEXT) eon.$(OBJEXT) wpc.$(OBJEXT) symtab.$(OBJEXT) \ - command.$(OBJEXT) fileio.$(OBJEXT) wpclib.$(OBJEXT) \ - imux.$(OBJEXT) ioexpand.$(OBJEXT) mmu.$(OBJEXT) \ - timer.$(OBJEXT) serial.$(OBJEXT) disk.$(OBJEXT) + machine.$(OBJEXT) eon.$(OBJEXT) wpc.$(OBJEXT) \ + miscsbc.$(OBJEXT) symtab.$(OBJEXT) command.$(OBJEXT) \ + fileio.$(OBJEXT) wpclib.$(OBJEXT) imux.$(OBJEXT) \ + ioexpand.$(OBJEXT) mmu.$(OBJEXT) timer.$(OBJEXT) \ + serial.$(OBJEXT) disk.$(OBJEXT) m6809_run_OBJECTS = $(am_m6809_run_OBJECTS) m6809_run_LDADD = $(LDADD) binSCRIPT_INSTALL = $(INSTALL_SCRIPT) @@ -121,6 +121,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ READLINE_LIBS = @READLINE_LIBS@ @@ -164,7 +165,7 @@ sharedstatedir = @sharedstatedir@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ m6809_run_SOURCES = \ - 6809.c main.c monitor.c machine.c eon.c wpc.c \ + 6809.c main.c monitor.c machine.c eon.c wpc.c miscsbc.c \ symtab.c command.c fileio.c wpclib.c imux.c \ ioexpand.c mmu.c timer.c serial.c disk.c \ 6809.h config.h eon.h machine.h monitor.h wpclib.h @@ -286,6 +287,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ioexpand.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/machine.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/miscsbc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mmu.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/monitor.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/serial.Po@am__quote@ @@ -386,7 +388,8 @@ distdir: $(DISTFILES) || exit 1; \ fi; \ done - -find $(distdir) -type d ! -perm -777 -exec chmod a+rwx {} \; -o \ + -find "$(distdir)" -type d ! -perm -755 \ + -exec chmod u+rwx,go+rx {} \; -o \ ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \ ! -type d ! -perm -400 -exec chmod a+r {} \; -o \ ! -type d ! -perm -444 -exec $(SHELL) $(install_sh) -c -m a+r {} {} \; \ @@ -432,7 +435,7 @@ distcheck: dist *.zip*) \ unzip $(distdir).zip ;;\ esac - chmod -R a-w $(distdir); chmod a+w $(distdir) + chmod -R a-w $(distdir); chmod u+w $(distdir) mkdir $(distdir)/_build mkdir $(distdir)/_inst chmod a-w $(distdir) diff --git a/config.h.in b/config.h.in index 4e12524..24a1a64 100644 --- a/config.h.in +++ b/config.h.in @@ -100,6 +100,9 @@ /* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME +/* Define to the home page for this package. */ +#undef PACKAGE_URL + /* Define to the version of this package. */ #undef PACKAGE_VERSION diff --git a/configure b/configure index a0fd58b..f189971 100755 --- a/configure +++ b/configure @@ -1,20 +1,22 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.63 for m6809-run 0.92. +# Generated by GNU Autoconf 2.69 for m6809-run 0.92. # # Report bugs to . # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -22,23 +24,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -46,7 +40,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -57,7 +57,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -80,13 +80,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -96,15 +89,16 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +as_myself= +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -116,12 +110,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -133,7 +131,294 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org and +$0: brian@oddchange.com about your system, including any +$0: error possibly output before this message. Then install +$0: a modern shell, or manually run the script under such a +$0: shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -147,8 +432,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -168,415 +457,111 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits -if test "x$CONFIG_SHELL" = x; then - if (eval ":") 2>/dev/null; then - as_have_required=yes -else - as_have_required=no -fi + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } - if test $as_have_required = yes && (eval ": -(as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit } -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac -if as_func_ret_success; then - : +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi else - exitcode=1 - echo positional parameters were not saved. + as_ln_s='cp -pR' fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null -test \$exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=\$LINENO - as_lineno_2=\$LINENO - test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && - test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } -") 2> /dev/null; then - : -else - as_candidate_shells= - as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - case $as_dir in - /*) - for as_base in sh bash ksh sh5; do - as_candidate_shells="$as_candidate_shells $as_dir/$as_base" - done;; - esac -done -IFS=$as_save_IFS - - - for as_shell in $as_candidate_shells $SHELL; do - # Try only shells that exist, to save several forks. - if { test -f "$as_shell" || test -f "$as_shell.exe"; } && - { ("$as_shell") 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac - + test -d ./-p && rmdir ./-p + as_mkdir_p=false fi +as_test_x='test -x' +as_executable_p=as_fn_executable_p -: -_ASEOF -}; then - CONFIG_SHELL=$as_shell - as_have_required=yes - if { "$as_shell" 2> /dev/null <<\_ASEOF -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then - emulate sh - NULLCMD=: - # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which - # is contrary to our usage. Disable this feature. - alias -g '${1+"$@"}'='"$@"' - setopt NO_GLOB_SUBST -else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; -esac +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" -fi +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -: -(as_func_return () { - (exit $1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = "$1" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test $exitcode = 0) || { (exit 1); exit 1; } - -( - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } - -_ASEOF -}; then - break -fi - -fi - - done - - if test "x$CONFIG_SHELL" != x; then - for as_var in BASH_ENV ENV - do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var - done - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} -fi - - - if test $as_have_required = no; then - echo This script requires a shell more modern than all the - echo shells that I found on your system. Please install a - echo modern shell, or manually run the script under such a - echo shell if you do have one. - { (exit 1); exit 1; } -fi - - -fi - -fi - - - -(eval "as_func_return () { - (exit \$1) -} -as_func_success () { - as_func_return 0 -} -as_func_failure () { - as_func_return 1 -} -as_func_ret_success () { - return 0 -} -as_func_ret_failure () { - return 1 -} - -exitcode=0 -if as_func_success; then - : -else - exitcode=1 - echo as_func_success failed. -fi - -if as_func_failure; then - exitcode=1 - echo as_func_failure succeeded. -fi - -if as_func_ret_success; then - : -else - exitcode=1 - echo as_func_ret_success failed. -fi - -if as_func_ret_failure; then - exitcode=1 - echo as_func_ret_failure succeeded. -fi - -if ( set x; as_func_ret_success y && test x = \"\$1\" ); then - : -else - exitcode=1 - echo positional parameters were not saved. -fi - -test \$exitcode = 0") || { - echo No shell found that supports shell functions. - echo Please tell bug-autoconf@gnu.org about your system, - echo including any error possibly output before this message. - echo This can help us improve future autoconf versions. - echo Configuration will now proceed without shell functions. -} - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi - -ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in --n*) - case `echo 'x\c'` in - *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; - esac;; -*) - ECHO_N='-n';; -esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi - -rm -f conf$$ conf$$.exe conf$$.file -if test -d conf$$.dir; then - rm -f conf$$.dir/conf$$.file -else - rm -f conf$$.dir - mkdir conf$$.dir 2>/dev/null -fi -if (echo >conf$$.file) 2>/dev/null; then - if ln -s conf$$.file conf$$ 2>/dev/null; then - as_ln_s='ln -s' - # ... but there are two gotchas: - # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. - # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. - ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' - elif ln conf$$.file conf$$ 2>/dev/null; then - as_ln_s=ln - else - as_ln_s='cp -p' - fi -else - as_ln_s='cp -p' -fi -rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file -rmdir conf$$.dir 2>/dev/null - -if mkdir -p . 2>/dev/null; then - as_mkdir_p=: -else - test -d ./-p && rmdir ./-p - as_mkdir_p=false -fi - -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x - -# Sed expression to map a string onto a valid CPP name. -as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" - -# Sed expression to map a string onto a valid variable name. -as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" - - - -exec 7<&0 &1 +test -n "$DJDIR" || exec 7<&0 &1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -591,7 +576,6 @@ cross_compiling=no subdirs= MFLAGS= MAKEFLAGS= -SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='m6809-run' @@ -599,6 +583,7 @@ PACKAGE_TARNAME='m6809-run' PACKAGE_VERSION='0.92' PACKAGE_STRING='m6809-run 0.92' PACKAGE_BUGREPORT='brian@oddchange.com' +PACKAGE_URL='' ac_unique_file="6809.c" # Factoring default headers for most tests. @@ -710,6 +695,7 @@ bindir program_transform_name prefix exec_prefix +PACKAGE_URL PACKAGE_BUGREPORT PACKAGE_STRING PACKAGE_VERSION @@ -796,8 +782,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -842,8 +829,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -869,8 +855,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid feature name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1074,8 +1059,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1091,8 +1075,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid package name: $ac_useropt" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1122,17 +1105,17 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) { $as_echo "$as_me: error: unrecognized option: $ac_option -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` # Reject names that are not valid shell variable names. - expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && - { $as_echo "$as_me: error: invalid variable name: $ac_envvar" >&2 - { (exit 1); exit 1; }; } + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1141,7 +1124,7 @@ Try \`$0 --help' for more information." >&2 $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1149,15 +1132,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - { $as_echo "$as_me: error: missing argument to $ac_option" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) { $as_echo "$as_me: error: unrecognized options: $ac_unrecognized_opts" >&2 - { (exit 1); exit 1; }; } ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1180,8 +1161,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - { $as_echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1195,8 +1175,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1211,11 +1189,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - { $as_echo "$as_me: error: working directory cannot be determined" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - { $as_echo "$as_me: error: pwd does not report name of working directory" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1254,13 +1230,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - { $as_echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || { $as_echo "$as_me: error: $ac_msg" >&2 - { (exit 1); exit 1; }; } + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1300,7 +1274,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1372,7 +1346,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L if you have libraries in a nonstandard directory LIBS libraries to pass to the linker, e.g. -l - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if you have headers in a nonstandard directory CPP C preprocessor @@ -1443,73 +1417,482 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF m6809-run configure 0.92 -generated by GNU Autoconf 2.63 +generated by GNU Autoconf 2.69 -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -2002, 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF exit fi -cat >config.log <<_ACEOF -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by m6809-run $as_me 0.92, which was -generated by GNU Autoconf 2.63. Invocation command line was - $ $0 $@ +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## -_ACEOF -exec 5>>config.log +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () { -cat <<_ASUNAME -## --------- ## -## Platform. ## -## --------- ## - -hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` -uname -m = `(uname -m) 2>/dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval -/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` -/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` -/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` -/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` +} # ac_fn_c_try_compile -_ASUNAME +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 -as_save_IFS=$IFS; IFS=$PATH_SEPARATOR -for as_dir in $PATH -do - IFS=$as_save_IFS - test -z "$as_dir" && as_dir=. - $as_echo "PATH: $as_dir" -done -IFS=$as_save_IFS + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval -} >&5 +} # ac_fn_c_try_cpp -cat >&5 <<_ACEOF +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval -## ----------- ## -## Core tests. ## -## ----------- ## +} # ac_fn_c_try_run +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> _ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } - -# Keep a trace of the command line. +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} +( $as_echo "## ---------------------------------- ## +## Report this to brian@oddchange.com ## +## ---------------------------------- ##" + ) | sed "s/^/$as_me: WARNING: /" >&2 + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_check_func LINENO FUNC VAR +# ---------------------------------- +# Tests whether FUNC exists, setting the cache variable VAR accordingly +ac_fn_c_check_func () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +/* Define $2 to an innocuous variant, in case declares $2. + For example, HP-UX 11i declares gettimeofday. */ +#define $2 innocuous_$2 + +/* System header to define __stub macros and hopefully few prototypes, + which can conflict with char $2 (); below. + Prefer to if __STDC__ is defined, since + exists even on freestanding compilers. */ + +#ifdef __STDC__ +# include +#else +# include +#endif + +#undef $2 + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char $2 (); +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined __stub_$2 || defined __stub___$2 +choke me +#endif + +int +main () +{ +return $2 (); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_link "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_func +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by m6809-run $as_me 0.92, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. # Strip out --no-create and --no-recursion so they do not pile up. # Strip out --silent because we don't want to record it for future runs. # Also quote any args containing shell meta-characters. @@ -1531,9 +1914,9 @@ do ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; esac case $ac_pass in - 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; 2) - ac_configure_args1="$ac_configure_args1 '$ac_arg'" + as_fn_append ac_configure_args1 " '$ac_arg'" if test $ac_must_keep_next = true; then ac_must_keep_next=false # Got value, back to normal. else @@ -1549,13 +1932,13 @@ do -* ) ac_must_keep_next=true ;; esac fi - ac_configure_args="$ac_configure_args '$ac_arg'" + as_fn_append ac_configure_args " '$ac_arg'" ;; esac done done -$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } -$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} # When interrupted or exit'd, cleanup temporary files, and complete # config.log. We remove comments because anyway the quotes in there @@ -1567,11 +1950,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -1580,13 +1961,13 @@ _ASBOX case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -1605,11 +1986,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -1622,11 +2001,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -1640,11 +2017,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -1658,46 +2033,53 @@ _ASBOX exit $exit_status ' 0 for ac_signal in 1 2 13 15; do - trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal done ac_signal=0 # confdefs.h avoids OS command line length limits that DEFS can exceed. rm -f -r conftest* confdefs.h +$as_echo "/* confdefs.h */" > confdefs.h + # Predefined preprocessor variables. cat >>confdefs.h <<_ACEOF #define PACKAGE_NAME "$PACKAGE_NAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_TARNAME "$PACKAGE_TARNAME" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_VERSION "$PACKAGE_VERSION" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_STRING "$PACKAGE_STRING" _ACEOF - cat >>confdefs.h <<_ACEOF #define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" _ACEOF +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + # Let the site file select an alternate cache file if it wants to. # Prefer an explicitly selected file to automatically selected ones. ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -1708,19 +2090,23 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then - { $as_echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then - { $as_echo "$as_me:$LINENO: loading cache $cache_file" >&5 + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in [\\/]* | ?:[\\/]* ) . "$cache_file";; @@ -1728,7 +2114,7 @@ $as_echo "$as_me: loading cache $cache_file" >&6;} esac fi else - { $as_echo "$as_me:$LINENO: creating cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 $as_echo "$as_me: creating cache $cache_file" >&6;} >$cache_file fi @@ -1743,11 +2129,11 @@ for ac_var in $ac_precious_vars; do eval ac_new_val=\$ac_env_${ac_var}_value case $ac_old_set,$ac_new_set in set,) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} ac_cache_corrupted=: ;; ,set) - { $as_echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_cache_corrupted=: ;; ,);; @@ -1757,17 +2143,17 @@ $as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} ac_old_val_w=`echo x $ac_old_val` ac_new_val_w=`echo x $ac_new_val` if test "$ac_old_val_w" != "$ac_new_val_w"; then - { $as_echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 $as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} ac_cache_corrupted=: else - { $as_echo "$as_me:$LINENO: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 $as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} eval $ac_var=\$ac_old_val fi - { $as_echo "$as_me:$LINENO: former value: \`$ac_old_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 $as_echo "$as_me: former value: \`$ac_old_val'" >&2;} - { $as_echo "$as_me:$LINENO: current value: \`$ac_new_val'" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} fi;; esac @@ -1779,43 +2165,20 @@ $as_echo "$as_me: current value: \`$ac_new_val'" >&2;} esac case " $ac_configure_args " in *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. - *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) as_fn_append ac_configure_args " '$ac_arg'" ;; esac fi done if $ac_cache_corrupted; then - { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} - { $as_echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - { { $as_echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 -$as_echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi - - - - - - - - - - - - - - - - - - - - - - - - +## -------------------- ## +## Main body of script. ## +## -------------------- ## ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -1843,9 +2206,7 @@ for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do fi done if test -z "$ac_aux_dir"; then - { { $as_echo "$as_me:$LINENO: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&5 -$as_echo "$as_me: error: cannot find install-sh or install.sh in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -1871,10 +2232,10 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # OS/2's system install, which has a completely different semantic # ./install, which can be erroneously created by make from ./install.sh. # Reject install programs that cannot install multiple files. -{ $as_echo "$as_me:$LINENO: checking for a BSD-compatible install" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -1882,11 +2243,11 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - # Account for people who put trailing slashes in PATH elements. -case $as_dir/ in - ./ | .// | /cC/* | \ + # Account for people who put trailing slashes in PATH elements. +case $as_dir/ in #(( + ./ | .// | /[cC]/* | \ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \ - ?:\\/os2\\/install\\/* | ?:\\/OS2\\/INSTALL\\/* | \ + ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \ /usr/ucb/* ) ;; *) # OSF1 and SCO ODT 3.0 have their own names for install. @@ -1894,7 +2255,7 @@ case $as_dir/ in # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -1923,7 +2284,7 @@ case $as_dir/ in ;; esac -done + done IFS=$as_save_IFS rm -rf conftest.one conftest.two conftest.dir @@ -1939,7 +2300,7 @@ fi INSTALL=$ac_install_sh fi fi -{ $as_echo "$as_me:$LINENO: result: $INSTALL" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5 $as_echo "$INSTALL" >&6; } # Use test -z because SunOS4 sh mishandles braces in ${var-val}. @@ -1950,7 +2311,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}' test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' -{ $as_echo "$as_me:$LINENO: checking whether build environment is sane" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5 $as_echo_n "checking whether build environment is sane... " >&6; } # Just in case sleep 1 @@ -1974,11 +2335,8 @@ if ( # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". - { { $as_echo "$as_me:$LINENO: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&5 -$as_echo "$as_me: error: ls -t appears to fail. Make sure there is not a broken -alias in your environment" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "ls -t appears to fail. Make sure there is not a broken +alias in your environment" "$LINENO" 5 fi test "$2" = conftest.file @@ -1987,13 +2345,10 @@ then # Ok. : else - { { $as_echo "$as_me:$LINENO: error: newly created file is older than distributed files! -Check your system clock" >&5 -$as_echo "$as_me: error: newly created file is older than distributed files! -Check your system clock" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "newly created file is older than distributed files! +Check your system clock" "$LINENO" 5 fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } test "$program_prefix" != NONE && program_transform_name="s&^&$program_prefix&;$program_transform_name" @@ -2014,7 +2369,7 @@ if eval "$MISSING --run true"; then am_missing_run="$MISSING --run " else am_missing_run= - { $as_echo "$as_me:$LINENO: WARNING: \`missing' script is too old or missing" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5 $as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;} fi @@ -2055,9 +2410,9 @@ for ac_prog in gawk mawk nawk awk do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_AWK+set}" = set; then +if ${ac_cv_prog_AWK+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$AWK"; then @@ -2068,24 +2423,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_AWK="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi AWK=$ac_cv_prog_AWK if test -n "$AWK"; then - { $as_echo "$as_me:$LINENO: result: $AWK" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5 $as_echo "$AWK" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2093,11 +2448,11 @@ fi test -n "$AWK" && break done -{ $as_echo "$as_me:$LINENO: checking whether ${MAKE-make} sets \$(MAKE)" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5 $as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; } set x ${MAKE-make} ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'` -if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then +if eval \${ac_cv_prog_make_${ac_make}_set+:} false; then : $as_echo_n "(cached) " >&6 else cat >conftest.make <<\_ACEOF @@ -2105,7 +2460,7 @@ SHELL = /bin/sh all: @echo '@@@%%%=$(MAKE)=@@@%%%' _ACEOF -# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +# GNU make sometimes prints "make[1]: Entering ...", which would confuse us. case `${MAKE-make} -f conftest.make 2>/dev/null` in *@@@%%%=?*=@@@%%%*) eval ac_cv_prog_make_${ac_make}_set=yes;; @@ -2115,11 +2470,11 @@ esac rm -f conftest.make fi if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then - { $as_echo "$as_me:$LINENO: result: yes" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 $as_echo "yes" >&6; } SET_MAKE= else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } SET_MAKE="MAKE=${MAKE-make}" fi @@ -2136,9 +2491,7 @@ rmdir .tst 2>/dev/null # test to see if srcdir already configured if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then - { { $as_echo "$as_me:$LINENO: error: source directory already configured; run \"make distclean\" there first" >&5 -$as_echo "$as_me: error: source directory already configured; run \"make distclean\" there first" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "source directory already configured; run \"make distclean\" there first" "$LINENO" 5 fi # test whether we have cygpath @@ -2191,9 +2544,9 @@ if test "$cross_compiling" != no; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args. set dummy ${ac_tool_prefix}strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_STRIP+set}" = set; then +if ${ac_cv_prog_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$STRIP"; then @@ -2204,24 +2557,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_STRIP="${ac_tool_prefix}strip" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi STRIP=$ac_cv_prog_STRIP if test -n "$STRIP"; then - { $as_echo "$as_me:$LINENO: result: $STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5 $as_echo "$STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2231,9 +2584,9 @@ if test -z "$ac_cv_prog_STRIP"; then ac_ct_STRIP=$STRIP # Extract the first word of "strip", so it can be a program name with args. set dummy strip; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then +if ${ac_cv_prog_ac_ct_STRIP+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_STRIP"; then @@ -2244,24 +2597,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_STRIP="strip" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP if test -n "$ac_ct_STRIP"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_STRIP" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5 $as_echo "$ac_ct_STRIP" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2270,7 +2623,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2307,9 +2660,9 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. set dummy ${ac_tool_prefix}gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2320,24 +2673,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2347,9 +2700,9 @@ if test -z "$ac_cv_prog_CC"; then ac_ct_CC=$CC # Extract the first word of "gcc", so it can be a program name with args. set dummy gcc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2360,24 +2713,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2386,7 +2739,7 @@ fi else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2400,9 +2753,9 @@ if test -z "$CC"; then if test -n "$ac_tool_prefix"; then # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. set dummy ${ac_tool_prefix}cc; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2413,24 +2766,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2440,9 +2793,9 @@ fi 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 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2454,18 +2807,18 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue fi ac_cv_prog_CC="cc" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS if test $ac_prog_rejected = yes; then @@ -2484,10 +2837,10 @@ fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2499,9 +2852,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. set dummy $ac_tool_prefix$ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2512,24 +2865,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi CC=$ac_cv_prog_CC if test -n "$CC"; then - { $as_echo "$as_me:$LINENO: result: $CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 $as_echo "$CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2543,9 +2896,9 @@ if test -z "$CC"; then do # Extract the first word of "$ac_prog", so it can be a program name with args. set dummy $ac_prog; ac_word=$2 -{ $as_echo "$as_me:$LINENO: checking for $ac_word" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2556,24 +2909,24 @@ for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" - $as_echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 fi done -done + done IFS=$as_save_IFS fi fi ac_ct_CC=$ac_cv_prog_ac_ct_CC if test -n "$ac_ct_CC"; then - { $as_echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 $as_echo "$ac_ct_CC" >&6; } else - { $as_echo "$as_me:$LINENO: result: no" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 $as_echo "no" >&6; } fi @@ -2586,7 +2939,7 @@ done else case $cross_compiling:$ac_tool_warned in yes:) -{ $as_echo "$as_me:$LINENO: WARNING: using cross tools not prefixed with host triplet" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} ac_tool_warned=yes ;; esac @@ -2597,57 +2950,37 @@ fi fi -test -z "$CC" && { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: no acceptable C compiler found in \$PATH -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. -$as_echo "$as_me:$LINENO: checking for C compiler version" >&5 +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 set X $ac_compile ac_compiler=$2 -{ (ac_try="$ac_compiler --version >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler --version >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -v >&5" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -v >&5") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } -{ (ac_try="$ac_compiler -V >&5" +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compiler -V >&5") 2>&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2663,8 +2996,8 @@ ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -2680,17 +3013,17 @@ do done rm -f $ac_rmfiles -if { (ac_try="$ac_link_default" +if { { ac_try="$ac_link_default" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link_default") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. # So ignore a value of `no', otherwise this would lead to `EXEEXT = no' # in a Makefile. We should not override ac_cv_exeext if it was cached, @@ -2707,7 +3040,7 @@ do # certainly right. break;; *.* ) - if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; then :; else ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` fi @@ -2726,84 +3059,41 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi - -{ $as_echo "$as_me:$LINENO: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } -if test -z "$ac_file"; then - $as_echo "$as_me: failed program was:" >&5 +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C compiler cannot create executables -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C compiler cannot create executables -See \`config.log' for more details." >&2;} - { (exit 77); exit 77; }; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi - +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } - fi - fi -fi -{ $as_echo "$as_me:$LINENO: result: yes" >&5 -$as_echo "yes" >&6; } - rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:$LINENO: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - -{ $as_echo "$as_me:$LINENO: checking for suffix of executables" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } -if { (ac_try="$ac_link" +if { { ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_link") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : # If both `conftest.exe' and `conftest' are `present' (well, observable) # catch `conftest.exe'. For instance with Cygwin, `ls conftest' will # work properly (i.e., refer to `conftest.exe'), while it won't with @@ -2818,32 +3108,83 @@ for ac_file in conftest.exe conftest conftest.*; do esac done else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi - -rm -f conftest$ac_cv_exeext -{ $as_echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT -{ $as_echo "$as_me:$LINENO: checking for suffix of object files" >&5 +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2855,17 +3196,17 @@ main () } _ACEOF rm -f conftest.o conftest.obj -if { (ac_try="$ac_compile" +if { { ac_try="$ac_compile" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; *) ac_try_echo=$ac_try;; esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 (eval "$ac_compile") 2>&5 ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; then + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : for ac_file in conftest.o conftest.obj conftest.*; do test -f "$ac_file" || continue; case $ac_file in @@ -2878,31 +3219,23 @@ else $as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 -{ { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: cannot compute suffix of object files: cannot compile -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi - rm -f conftest.$ac_cv_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 $as_echo "$ac_cv_objext" >&6; } OBJEXT=$ac_cv_objext ac_objext=$OBJEXT -{ $as_echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2916,37 +3249,16 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_compiler_gnu=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_compiler_gnu=no + ac_compiler_gnu=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_cv_c_compiler_gnu=$ac_compiler_gnu fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 $as_echo "$ac_cv_c_compiler_gnu" >&6; } if test $ac_compiler_gnu = yes; then GCC=yes @@ -2955,20 +3267,16 @@ else fi ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS -{ $as_echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag ac_c_werror_flag=yes ac_cv_prog_cc_g=no CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -2979,35 +3287,11 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - CFLAGS="" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3018,36 +3302,12 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_compile "$LINENO"; then : - ac_c_werror_flag=$ac_save_c_werror_flag +else + ac_c_werror_flag=$ac_save_c_werror_flag CFLAGS="-g" - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -3058,42 +3318,17 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_g=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext ac_c_werror_flag=$ac_save_c_werror_flag fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 $as_echo "$ac_cv_prog_cc_g" >&6; } if test "$ac_test_CFLAGS" = set; then CFLAGS=$ac_save_CFLAGS @@ -3110,23 +3345,18 @@ else CFLAGS= fi fi -{ $as_echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no ac_save_CC=$CC -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF +cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include -#include -#include +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3178,32 +3408,9 @@ for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" do CC="$ac_save_CC $ac_arg" - rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then + if ac_fn_c_try_compile "$LINENO"; then : ac_cv_prog_cc_c89=$ac_arg -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext test "x$ac_cv_prog_cc_c89" != "xno" && break done @@ -3214,17 +3421,19 @@ fi # AC_CACHE_VAL case "x$ac_cv_prog_cc_c89" in x) - { $as_echo "$as_me:$LINENO: result: none needed" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 $as_echo "none needed" >&6; } ;; xno) - { $as_echo "$as_me:$LINENO: result: unsupported" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 $as_echo "unsupported" >&6; } ;; *) CC="$CC $ac_cv_prog_cc_c89" - { $as_echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 $as_echo "$ac_cv_prog_cc_c89" >&6; } ;; esac +if test "x$ac_cv_prog_cc_c89" != xno; then : +fi ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3243,7 +3452,7 @@ am__doit: .PHONY: am__doit END # If we don't find an include directive, just comment out the code. -{ $as_echo "$as_me:$LINENO: checking for style of include used by $am_make" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5 $as_echo_n "checking for style of include used by $am_make... " >&6; } am__include="#" am__quote= @@ -3271,12 +3480,12 @@ if test "$am__include" = "#"; then fi -{ $as_echo "$as_me:$LINENO: result: $_am_result" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5 $as_echo "$_am_result" >&6; } rm -f confinc confmf # Check whether --enable-dependency-tracking was given. -if test "${enable_dependency_tracking+set}" = set; then +if test "${enable_dependency_tracking+set}" = set; then : enableval=$enable_dependency_tracking; fi @@ -3299,9 +3508,9 @@ fi depcc="$CC" am_compiler_list= -{ $as_echo "$as_me:$LINENO: checking dependency style of $depcc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5 $as_echo_n "checking dependency style of $depcc... " >&6; } -if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then +if ${am_cv_CC_dependencies_compiler_type+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then @@ -3389,7 +3598,7 @@ else fi fi -{ $as_echo "$as_me:$LINENO: result: $am_cv_CC_dependencies_compiler_type" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5 $as_echo "$am_cv_CC_dependencies_compiler_type" >&6; } CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type @@ -3414,14 +3623,14 @@ ac_cpp='$CPP $CPPFLAGS' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 $as_echo_n "checking how to run the C preprocessor... " >&6; } # On Suns, sometimes $CPP names a directory. if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -3436,11 +3645,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -3449,78 +3654,34 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : break fi @@ -3532,7 +3693,7 @@ fi else ac_cv_prog_CPP=$CPP fi -{ $as_echo "$as_me:$LINENO: result: $CPP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 $as_echo "$CPP" >&6; } ac_preproc_ok=false for ac_c_preproc_warn_flag in '' yes @@ -3543,11 +3704,7 @@ do # exists even on freestanding compilers. # On the NeXT, cc -E runs the code through the compiler's parser, # not just through cpp. "Syntax error" is here to catch this case. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifdef __STDC__ # include @@ -3556,87 +3713,40 @@ cat >>conftest.$ac_ext <<_ACEOF #endif Syntax error _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - : -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_cpp "$LINENO"; then : +else # Broken: fails on valid input. continue fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then +if ac_fn_c_try_cpp "$LINENO"; then : # Broken: success on invalid input. continue else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - # Passes both tests. ac_preproc_ok=: break fi - -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext -if $ac_preproc_ok; then - : +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + else - { { $as_echo "$as_me:$LINENO: error: in \`$ac_pwd':" >&5 + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ { $as_echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&5 -$as_echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." >&2;} - { (exit 1); exit 1; }; }; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -3646,9 +3756,9 @@ ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $ ac_compiler_gnu=$ac_cv_c_compiler_gnu -{ $as_echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -3659,10 +3769,10 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in grep ggrep; do + for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3679,7 +3789,7 @@ case `"$ac_path_GREP" --version 2>&1` in $as_echo 'GREP' >> "conftest.nl" "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_GREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_GREP="$ac_path_GREP" @@ -3694,26 +3804,24 @@ esac $ac_path_GREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 $as_echo "$ac_cv_path_GREP" >&6; } GREP="$ac_cv_path_GREP" -{ $as_echo "$as_me:$LINENO: checking for egrep" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -3727,10 +3835,10 @@ for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - for ac_prog in egrep; do + for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3747,7 +3855,7 @@ case `"$ac_path_EGREP" --version 2>&1` in $as_echo 'EGREP' >> "conftest.nl" "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break - ac_count=`expr $ac_count + 1` + as_fn_arith $ac_count + 1 && ac_count=$as_val if test $ac_count -gt ${ac_path_EGREP_max-0}; then # Best one so far, save it but keep looking for a better one ac_cv_path_EGREP="$ac_path_EGREP" @@ -3762,12 +3870,10 @@ esac $ac_path_EGREP_found && break 3 done done -done + done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - { { $as_echo "$as_me:$LINENO: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 -$as_echo "$as_me: error: no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -3775,21 +3881,17 @@ fi fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 $as_echo "$ac_cv_path_EGREP" >&6; } EGREP="$ac_cv_path_EGREP" -{ $as_echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -3804,48 +3906,23 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_stdc=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_stdc=no + ac_cv_header_stdc=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_header_stdc = yes; then # SunOS 4.x string.h does not declare mem*, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "memchr" >/dev/null 2>&1; then - : + $EGREP "memchr" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -3855,18 +3932,14 @@ fi if test $ac_cv_header_stdc = yes; then # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include _ACEOF if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | - $EGREP "free" >/dev/null 2>&1; then - : + $EGREP "free" >/dev/null 2>&1; then : + else ac_cv_header_stdc=no fi @@ -3876,14 +3949,10 @@ fi if test $ac_cv_header_stdc = yes; then # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : : else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -3910,277 +3979,47 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then - : -else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 +if ac_fn_c_try_run "$LINENO"; then : -( exit $ac_status ) -ac_cv_header_stdc=no +else + ac_cv_header_stdc=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 $as_echo "$ac_cv_header_stdc" >&6; } if test $ac_cv_header_stdc = yes; then -cat >>confdefs.h <<\_ACEOF -#define STDC_HEADERS 1 -_ACEOF +$as_echo "#define STDC_HEADERS 1" >>confdefs.h fi # On IRIX 5.3, sys/types and inttypes.h are conflicting. - - - - - - - - - -for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ - inttypes.h stdint.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default - -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - eval "$as_ac_Header=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_Header=no" -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 -_ACEOF +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF fi done - - - - - - - - for ac_header in netinet/in.h stdint.h stdlib.h string.h sys/socket.h sys/time.h termios.h unistd.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to brian@oddchange.com ## -## ---------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4191,19 +4030,14 @@ done # Checks for typedefs, structures, and compiler characteristics. - - { $as_echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then +if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown # See if we're dealing with a universal compiler. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __APPLE_CC__ not a universal capable compiler @@ -4211,46 +4045,34 @@ cat >>conftest.$ac_ext <<_ACEOF typedef int dummy; _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : # Check for potential -arch flags. It is not universal unless - # there are some -arch flags. Note that *ppc* also matches - # ppc64. This check is also rather less than ideal. - case "${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS}" in #( - *-arch*ppc*|*-arch*i386*|*-arch*x86_64*) ac_cv_c_bigendian=universal;; - esac -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext if test $ac_cv_c_bigendian = unknown; then # See if sys/param.h defines the BYTE_ORDER macro. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4268,30 +4090,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4307,49 +4108,18 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -4364,30 +4134,9 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : # It does; now see whether it defined to _BIG_ENDIAN or not. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include @@ -4402,51 +4151,20 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_bigendian=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_bigendian=no + ac_cv_c_bigendian=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi if test $ac_cv_c_bigendian = unknown; then # Compile a test program. - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : # Try to guess by grepping values from an object file. - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; @@ -4472,24 +4190,7 @@ return use_ascii (foo) == use_ebcdic (foo); return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then ac_cv_c_bigendian=yes fi @@ -4501,20 +4202,10 @@ $as_echo "$ac_try_echo") >&5 ac_cv_c_bigendian=unknown fi fi -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default int @@ -4534,89 +4225,51 @@ main () return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_run "$LINENO"; then : ac_cv_c_bigendian=no else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_c_bigendian=yes + ac_cv_c_bigendian=yes fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 $as_echo "$ac_cv_c_bigendian" >&6; } case $ac_cv_c_bigendian in #( yes) - cat >>confdefs.h <<\_ACEOF -#define WORDS_BIGENDIAN 1 -_ACEOF + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h ;; #( no) ;; #( universal) -cat >>confdefs.h <<\_ACEOF -#define AC_APPLE_UNIVERSAL_BUILD 1 -_ACEOF +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) - { { $as_echo "$as_me:$LINENO: error: unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" >&5 -$as_echo "$as_me: error: unknown endianness - presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} - { (exit 1); exit 1; }; } ;; + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac -{ $as_echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then +if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -4633,8 +4286,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -4650,10 +4304,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -4666,56 +4320,29 @@ main () return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_const=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_const=no + ac_cv_c_const=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 $as_echo "$ac_cv_c_const" >&6; } if test $ac_cv_c_const = no; then -cat >>confdefs.h <<\_ACEOF -#define const /**/ -_ACEOF +$as_echo "#define const /**/" >>confdefs.h fi -{ $as_echo "$as_me:$LINENO: checking for inline" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5 $as_echo_n "checking for inline... " >&6; } -if test "${ac_cv_c_inline+set}" = set; then +if ${ac_cv_c_inline+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_inline=no for ac_kw in inline __inline__ __inline; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #ifndef __cplusplus typedef int foo_t; @@ -4724,41 +4351,17 @@ $ac_kw foo_t foo () {return 0; } #endif _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_inline=$ac_kw -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext test "$ac_cv_c_inline" != no && break done fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_inline" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5 $as_echo "$ac_cv_c_inline" >&6; } - case $ac_cv_c_inline in inline | yes) ;; *) @@ -4774,16 +4377,12 @@ _ACEOF ;; esac -{ $as_echo "$as_me:$LINENO: checking whether time.h and sys/time.h may both be included" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then +if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -4798,107 +4397,23 @@ return 0; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_header_time=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_header_time=no + ac_cv_header_time=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_header_time" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5 $as_echo "$ac_cv_header_time" >&6; } if test $ac_cv_header_time = yes; then -cat >>confdefs.h <<\_ACEOF -#define TIME_WITH_SYS_TIME 1 -_ACEOF +$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h fi - - { $as_echo "$as_me:$LINENO: checking for uint16_t" >&5 -$as_echo_n "checking for uint16_t... " >&6; } -if test "${ac_cv_c_uint16_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_c_uint16_t=no - for ac_type in 'uint16_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (16 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - case $ac_type in - uint16_t) ac_cv_c_uint16_t=yes ;; - *) ac_cv_c_uint16_t=$ac_type ;; -esac - -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint16_t" != no && break - done -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_uint16_t" >&5 -$as_echo "$ac_cv_c_uint16_t" >&6; } - case $ac_cv_c_uint16_t in #( +ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" +case $ac_cv_c_uint16_t in #( no|yes) ;; #( *) @@ -4909,75 +4424,12 @@ _ACEOF ;; esac - - { $as_echo "$as_me:$LINENO: checking for uint32_t" >&5 -$as_echo_n "checking for uint32_t... " >&6; } -if test "${ac_cv_c_uint32_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_c_uint32_t=no - for ac_type in 'uint32_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (32 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - case $ac_type in - uint32_t) ac_cv_c_uint32_t=yes ;; - *) ac_cv_c_uint32_t=$ac_type ;; -esac - -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint32_t" != no && break - done -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_uint32_t" >&5 -$as_echo "$ac_cv_c_uint32_t" >&6; } - case $ac_cv_c_uint32_t in #( +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( no|yes) ;; #( *) -cat >>confdefs.h <<\_ACEOF -#define _UINT32_T 1 -_ACEOF +$as_echo "#define _UINT32_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF @@ -4986,75 +4438,12 @@ _ACEOF ;; esac - - { $as_echo "$as_me:$LINENO: checking for uint8_t" >&5 -$as_echo_n "checking for uint8_t... " >&6; } -if test "${ac_cv_c_uint8_t+set}" = set; then - $as_echo_n "(cached) " >&6 -else - ac_cv_c_uint8_t=no - for ac_type in 'uint8_t' 'unsigned int' 'unsigned long int' \ - 'unsigned long long int' 'unsigned short int' 'unsigned char'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -int -main () -{ -static int test_array [1 - 2 * !(($ac_type) -1 >> (8 - 1) == 1)]; -test_array [0] = 0 - - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - case $ac_type in - uint8_t) ac_cv_c_uint8_t=yes ;; - *) ac_cv_c_uint8_t=$ac_type ;; -esac - -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - test "$ac_cv_c_uint8_t" != no && break - done -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_uint8_t" >&5 -$as_echo "$ac_cv_c_uint8_t" >&6; } - case $ac_cv_c_uint8_t in #( +ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" +case $ac_cv_c_uint8_t in #( no|yes) ;; #( *) -cat >>confdefs.h <<\_ACEOF -#define _UINT8_T 1 -_ACEOF +$as_echo "#define _UINT8_T 1" >>confdefs.h cat >>confdefs.h <<_ACEOF @@ -5063,16 +4452,12 @@ _ACEOF ;; esac -{ $as_echo "$as_me:$LINENO: checking for working volatile" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5 $as_echo_n "checking for working volatile... " >&6; } -if test "${ac_cv_c_volatile+set}" = set; then +if ${ac_cv_c_volatile+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ int @@ -5086,210 +4471,44 @@ return !x && !y; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_c_volatile=yes else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_c_volatile=no + ac_cv_c_volatile=no fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_c_volatile" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5 $as_echo "$ac_cv_c_volatile" >&6; } if test $ac_cv_c_volatile = no; then -cat >>confdefs.h <<\_ACEOF -#define volatile /**/ -_ACEOF +$as_echo "#define volatile /**/" >>confdefs.h fi # Checks for library functions. - for ac_header in stdlib.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to brian@oddchange.com ## -## ---------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + ac_fn_c_check_header_mongrel "$LINENO" "stdlib.h" "ac_cv_header_stdlib_h" "$ac_includes_default" +if test "x$ac_cv_header_stdlib_h" = xyes; then : cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +#define HAVE_STDLIB_H 1 _ACEOF fi done -{ $as_echo "$as_me:$LINENO: checking for GNU libc compatible malloc" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU libc compatible malloc" >&5 $as_echo_n "checking for GNU libc compatible malloc... " >&6; } -if test "${ac_cv_func_malloc_0_nonnull+set}" = set; then +if ${ac_cv_func_malloc_0_nonnull+:} false; then : $as_echo_n "(cached) " >&6 else - if test "$cross_compiling" = yes; then + if test "$cross_compiling" = yes; then : ac_cv_func_malloc_0_nonnull=no else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #if defined STDC_HEADERS || defined HAVE_STDLIB_H # include @@ -5305,55 +4524,24 @@ return ! malloc (0); return 0; } _ACEOF -rm -f conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { ac_try='./conftest$ac_exeext' - { (case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); }; }; then +if ac_fn_c_try_run "$LINENO"; then : ac_cv_func_malloc_0_nonnull=yes else - $as_echo "$as_me: program exited with status $ac_status" >&5 -$as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - -( exit $ac_status ) -ac_cv_func_malloc_0_nonnull=no + ac_cv_func_malloc_0_nonnull=no fi -rm -rf conftest.dSYM -rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext fi - fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_malloc_0_nonnull" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_malloc_0_nonnull" >&5 $as_echo "$ac_cv_func_malloc_0_nonnull" >&6; } -if test $ac_cv_func_malloc_0_nonnull = yes; then +if test $ac_cv_func_malloc_0_nonnull = yes; then : -cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 1 -_ACEOF +$as_echo "#define HAVE_MALLOC 1" >>confdefs.h else - cat >>confdefs.h <<\_ACEOF -#define HAVE_MALLOC 0 -_ACEOF + $as_echo "#define HAVE_MALLOC 0" >>confdefs.h case " $LIBOBJS " in *" malloc.$ac_objext "* ) ;; @@ -5362,158 +4550,16 @@ _ACEOF esac -cat >>confdefs.h <<\_ACEOF -#define malloc rpl_malloc -_ACEOF +$as_echo "#define malloc rpl_malloc" >>confdefs.h fi - - - for ac_header in sys/select.h sys/socket.h -do -as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - { $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -else - # Is the header compilable? -{ $as_echo "$as_me:$LINENO: checking $ac_header usability" >&5 -$as_echo_n "checking $ac_header usability... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -$ac_includes_default -#include <$ac_header> -_ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then - ac_header_compiler=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_compiler=no -fi - -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 -$as_echo "$ac_header_compiler" >&6; } - -# Is the header present? -{ $as_echo "$as_me:$LINENO: checking $ac_header presence" >&5 -$as_echo_n "checking $ac_header presence... " >&6; } -cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -#include <$ac_header> -_ACEOF -if { (ac_try="$ac_cpp conftest.$ac_ext" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } >/dev/null && { - test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || - test ! -s conftest.err - }; then - ac_header_preproc=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_header_preproc=no -fi - -rm -f conftest.err conftest.$ac_ext -{ $as_echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 -$as_echo "$ac_header_preproc" >&6; } - -# So? What about this header? -case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in - yes:no: ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 -$as_echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} - ac_header_preproc=yes - ;; - no:yes:* ) - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 -$as_echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 -$as_echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 -$as_echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 -$as_echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 -$as_echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} - { $as_echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 -$as_echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} - ( cat <<\_ASBOX -## ---------------------------------- ## -## Report this to brian@oddchange.com ## -## ---------------------------------- ## -_ASBOX - ) | sed "s/^/$as_me: WARNING: /" >&2 - ;; -esac -{ $as_echo "$as_me:$LINENO: checking for $ac_header" >&5 -$as_echo_n "checking for $ac_header... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - eval "$as_ac_Header=\$ac_header_preproc" -fi -ac_res=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } - -fi -as_val=`eval 'as_val=${'$as_ac_Header'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -5522,19 +4568,15 @@ fi done -{ $as_echo "$as_me:$LINENO: checking types of arguments for select" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking types of arguments for select" >&5 $as_echo_n "checking types of arguments for select... " >&6; } -if test "${ac_cv_func_select_args+set}" = set; then +if ${ac_cv_func_select_args+:} false; then : $as_echo_n "(cached) " >&6 else for ac_arg234 in 'fd_set *' 'int *' 'void *'; do for ac_arg1 in 'int' 'size_t' 'unsigned long int' 'unsigned int'; do for ac_arg5 in 'struct timeval *' 'const struct timeval *'; do - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ $ac_includes_default #ifdef HAVE_SYS_SELECT_H @@ -5554,41 +4596,18 @@ extern int select ($ac_arg1, return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_func_select_args="$ac_arg1,$ac_arg234,$ac_arg5"; break 3 -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext done done done # Provide a safe default value. -: ${ac_cv_func_select_args='int,int *,struct timeval *'} +: "${ac_cv_func_select_args=int,int *,struct timeval *}" fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func_select_args" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_select_args" >&5 $as_echo "$ac_cv_func_select_args" >&6; } ac_save_IFS=$IFS; IFS=',' set dummy `echo "$ac_cv_func_select_args" | sed 's/\*/\*/g'` @@ -5611,16 +4630,12 @@ _ACEOF rm -f conftest* -{ $as_echo "$as_me:$LINENO: checking return type of signal handlers" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then +if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF + cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include #include @@ -5633,35 +4648,14 @@ return *(signal (0, 0)) (0) == 1; return 0; } _ACEOF -rm -f conftest.$ac_objext -if { (ac_try="$ac_compile" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_compile") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest.$ac_objext; then +if ac_fn_c_try_compile "$LINENO"; then : ac_cv_type_signal=int else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_type_signal=void + ac_cv_type_signal=void fi - rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_type_signal" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5 $as_echo "$ac_cv_type_signal" >&6; } cat >>confdefs.h <<_ACEOF @@ -5669,301 +4663,30 @@ cat >>confdefs.h <<_ACEOF _ACEOF - for ac_func in vprintf -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - eval "$as_ac_var=no" -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF - -{ $as_echo "$as_me:$LINENO: checking for _doprnt" >&5 -$as_echo_n "checking for _doprnt... " >&6; } -if test "${ac_cv_func__doprnt+set}" = set; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define _doprnt to an innocuous variant, in case declares _doprnt. - For example, HP-UX 11i declares gettimeofday. */ -#define _doprnt innocuous__doprnt - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char _doprnt (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef _doprnt - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char _doprnt (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub__doprnt || defined __stub____doprnt -choke me -#endif - -int -main () -{ -return _doprnt (); - ; - return 0; -} -_ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - ac_cv_func__doprnt=yes -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - - ac_cv_func__doprnt=no -fi - -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext -fi -{ $as_echo "$as_me:$LINENO: result: $ac_cv_func__doprnt" >&5 -$as_echo "$ac_cv_func__doprnt" >&6; } -if test "x$ac_cv_func__doprnt" = x""yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_DOPRNT 1 -_ACEOF - -fi - -fi -done - - - - - - - - - -for ac_func in gettimeofday memset select strchr strstr strtoul socket -do -as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -{ $as_echo "$as_me:$LINENO: checking for $ac_func" >&5 -$as_echo_n "checking for $ac_func... " >&6; } -if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then - $as_echo_n "(cached) " >&6 -else - cat >conftest.$ac_ext <<_ACEOF -/* confdefs.h. */ -_ACEOF -cat confdefs.h >>conftest.$ac_ext -cat >>conftest.$ac_ext <<_ACEOF -/* end confdefs.h. */ -/* Define $ac_func to an innocuous variant, in case declares $ac_func. - For example, HP-UX 11i declares gettimeofday. */ -#define $ac_func innocuous_$ac_func - -/* System header to define __stub macros and hopefully few prototypes, - which can conflict with char $ac_func (); below. - Prefer to if __STDC__ is defined, since - exists even on freestanding compilers. */ - -#ifdef __STDC__ -# include -#else -# include -#endif - -#undef $ac_func - -/* Override any GCC internal prototype to avoid an error. - Use char because int might match the return type of a GCC - builtin and then its argument prototype would still apply. */ -#ifdef __cplusplus -extern "C" -#endif -char $ac_func (); -/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_$ac_func || defined __stub___$ac_func -choke me -#endif - -int -main () -{ -return $ac_func (); - ; - return 0; -} +do : + ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" +if test "x$ac_cv_func_vprintf" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_VPRINTF 1 _ACEOF -rm -f conftest.$ac_objext conftest$ac_exeext -if { (ac_try="$ac_link" -case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:$LINENO: $ac_try_echo\"" -$as_echo "$ac_try_echo") >&5 - (eval "$ac_link") 2>conftest.er1 - ac_status=$? - grep -v '^ *+' conftest.er1 >conftest.err - rm -f conftest.er1 - cat conftest.err >&5 - $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 - (exit $ac_status); } && { - test -z "$ac_c_werror_flag" || - test ! -s conftest.err - } && test -s conftest$ac_exeext && { - test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext - }; then - eval "$as_ac_var=yes" -else - $as_echo "$as_me: failed program was:" >&5 -sed 's/^/| /' conftest.$ac_ext >&5 - eval "$as_ac_var=no" +ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" +if test "x$ac_cv_func__doprnt" = xyes; then : + +$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h + fi -rm -rf conftest.dSYM -rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ - conftest$ac_exeext conftest.$ac_ext fi -ac_res=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - { $as_echo "$as_me:$LINENO: result: $ac_res" >&5 -$as_echo "$ac_res" >&6; } -as_val=`eval 'as_val=${'$as_ac_var'} - $as_echo "$as_val"'` - if test "x$as_val" = x""yes; then +done + + +for ac_func in gettimeofday memset select strchr strstr strtoul socket +do : + as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` +ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -5973,7 +4696,7 @@ done # Check whether --enable-wpc was given. -if test "${enable_wpc+set}" = set; then +if test "${enable_wpc+set}" = set; then : enableval=$enable_wpc; wpc=$enableval else wpc=no @@ -5981,14 +4704,12 @@ fi if test $wpc = yes; then -cat >>confdefs.h <<\_ACEOF -#define CONFIG_WPC 1 -_ACEOF +$as_echo "#define CONFIG_WPC 1" >>confdefs.h fi # Check whether --enable-6309 was given. -if test "${enable_6309+set}" = set; then +if test "${enable_6309+set}" = set; then : enableval=$enable_6309; h6309=$enableval else h6309=no @@ -5996,14 +4717,12 @@ fi if test $h6309 = yes; then -cat >>confdefs.h <<\_ACEOF -#define H6309 1 -_ACEOF +$as_echo "#define H6309 1" >>confdefs.h fi # Check whether --enable-readline was given. -if test "${enable_readline+set}" = set; then +if test "${enable_readline+set}" = set; then : enableval=$enable_readline; rl_lib=$enableval else rl_lib=no @@ -6011,9 +4730,7 @@ fi if test $rl_lib = yes; then -cat >>confdefs.h <<\_ACEOF -#define HAVE_READLINE 1 -_ACEOF +$as_echo "#define HAVE_READLINE 1" >>confdefs.h READLINE_LIBS="-L/lib -lreadline" @@ -6048,13 +4765,13 @@ _ACEOF case $ac_val in #( *${as_nl}*) case $ac_var in #( - *_cv_*) { $as_echo "$as_me:$LINENO: WARNING: cache variable $ac_var contains a newline" >&5 + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; esac case $ac_var in #( _ | IFS | as_nl) ;; #( BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( - *) $as_unset $ac_var ;; + *) { eval $ac_var=; unset $ac_var;} ;; esac ;; esac done @@ -6062,8 +4779,8 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; (set) 2>&1 | case $as_nl`(ac_space=' '; set) 2>&1` in #( *${as_nl}ac_space=\ *) - # `set' does not quote correctly, so add quotes (double-quote - # substitution turns \\\\ into \\, and sed turns \\ into \). + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. sed -n \ "s/'/'\\\\''/g; s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" @@ -6085,12 +4802,23 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && - { $as_echo "$as_me:$LINENO: updating cache $cache_file" >&5 + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else - { $as_echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} fi fi @@ -6104,14 +4832,15 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' ac_i=`$as_echo "$ac_i" | sed "$ac_script"` # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR # will be set to the directory where LIBOBJS objects are built. - ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" - ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' done LIBOBJS=$ac_libobjs @@ -6119,28 +4848,23 @@ LTLIBOBJS=$ac_ltlibobjs if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then - { { $as_echo "$as_me:$LINENO: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -$as_echo "$as_me: error: conditional \"AMDEP\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "conditional \"AMDEP\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then - { { $as_echo "$as_me:$LINENO: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&5 -$as_echo "$as_me: error: conditional \"am__fastdepCC\" was never defined. -Usually this means the macro was only invoked conditionally." >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "conditional \"am__fastdepCC\" was never defined. +Usually this means the macro was only invoked conditionally." "$LINENO" 5 fi -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" -{ $as_echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 $as_echo "$as_me: creating $CONFIG_STATUS" >&6;} -cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 #! $SHELL # Generated by $as_me. # Run this file to recreate the current configuration. @@ -6150,17 +4874,18 @@ cat >$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 debug=false ac_cs_recheck=false ac_cs_silent=false -SHELL=\${CONFIG_SHELL-$SHELL} -_ACEOF -cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 -## --------------------- ## -## M4sh Initialization. ## -## --------------------- ## +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## # Be more Bourne compatible DUALCASE=1; export DUALCASE # for MKS sh -if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : emulate sh NULLCMD=: # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which @@ -6168,23 +4893,15 @@ if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then alias -g '${1+"$@"}'='"$@"' setopt NO_GLOB_SUBST else - case `(set -o) 2>/dev/null` in - *posix*) set -o posix ;; + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; esac - fi - - -# PATH needs CR -# Avoid depending upon Character Ranges. -as_cr_letters='abcdefghijklmnopqrstuvwxyz' -as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' -as_cr_Letters=$as_cr_letters$as_cr_LETTERS -as_cr_digits='0123456789' -as_cr_alnum=$as_cr_Letters$as_cr_digits - as_nl=' ' export as_nl @@ -6192,7 +4909,13 @@ export as_nl as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo -if (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then as_echo='printf %s\n' as_echo_n='printf %s' else @@ -6203,7 +4926,7 @@ else as_echo_body='eval expr "X$1" : "X\\(.*\\)"' as_echo_n_body='eval arg=$1; - case $arg in + case $arg in #( *"$as_nl"*) expr "X$arg" : "X\\(.*\\)$as_nl"; arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; @@ -6226,13 +4949,6 @@ if test "${PATH_SEPARATOR+set}" != set; then } fi -# Support unset when possible. -if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then - as_unset=unset -else - as_unset=false -fi - # IFS # We need space, tab and new line, in precisely that order. Quoting is @@ -6242,15 +4958,16 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. -case $0 in +as_myself= +case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR for as_dir in $PATH do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. - test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break -done + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done IFS=$as_save_IFS ;; @@ -6262,12 +4979,16 @@ if test "x$as_myself" = x; then fi if test ! -f "$as_myself"; then $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 - { (exit 1); exit 1; } + exit 1 fi -# Work around bugs in pre-3.0 UWIN ksh. -for as_var in ENV MAIL MAILPATH -do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : done PS1='$ ' PS2='> ' @@ -6279,7 +5000,89 @@ export LC_ALL LANGUAGE=C export LANGUAGE -# Required to use basename. +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + if expr a : '\(a\)' >/dev/null 2>&1 && test "X`expr 00001 : '.*\(...\)'`" = X001; then as_expr=expr @@ -6293,8 +5096,12 @@ else as_basename=false fi +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi -# Name of the executable. as_me=`$as_basename -- "$0" || $as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ X"$0" : 'X\(//\)$' \| \ @@ -6314,76 +5121,25 @@ $as_echo X/"$0" | } s/.*/./; q'` -# CDPATH. -$as_unset CDPATH - - - - as_lineno_1=$LINENO - as_lineno_2=$LINENO - test "x$as_lineno_1" != "x$as_lineno_2" && - test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { - - # Create $as_me.lineno as a copy of $as_myself, but with $LINENO - # uniformly replaced by the line number. The first 'sed' inserts a - # line-number line after each line using $LINENO; the second 'sed' - # does the real work. The second script uses 'N' to pair each - # line-number line with the line containing $LINENO, and appends - # trailing '-' during substitution so that $LINENO is not a special - # case at line end. - # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the - # scripts with optimization help from Paolo Bonzini. Blame Lee - # E. McMahon (1931-1989) for sed's syntax. :-) - sed -n ' - p - /[$]LINENO/= - ' <$as_myself | - sed ' - s/[$]LINENO.*/&-/ - t lineno - b - :lineno - N - :loop - s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ - t loop - s/-\n.*// - ' >$as_me.lineno && - chmod +x "$as_me.lineno" || - { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 - { (exit 1); exit 1; }; } - - # Don't try to exec as it changes $[0], causing all sort of problems - # (the dirname of $[0] is not the place where we might find the - # original and so on. Autoconf is especially sensitive to this). - . "./$as_me.lineno" - # Exit status is that of the last command. - exit -} - - -if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then - as_dirname=dirname -else - as_dirname=false -fi +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits ECHO_C= ECHO_N= ECHO_T= -case `echo -n x` in +case `echo -n x` in #((((( -n*) - case `echo 'x\c'` in + case `echo 'xy\c'` in *c*) ECHO_T=' ';; # ECHO_T is single tab character. - *) ECHO_C='\c';; + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; esac;; *) ECHO_N='-n';; esac -if expr a : '\(a\)' >/dev/null 2>&1 && - test "X`expr 00001 : '.*\(...\)'`" = X001; then - as_expr=expr -else - as_expr=false -fi rm -f conf$$ conf$$.exe conf$$.file if test -d conf$$.dir; then @@ -6398,49 +5154,85 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p if mkdir -p . 2>/dev/null; then - as_mkdir_p=: + as_mkdir_p='mkdir -p "$as_dir"' else test -d ./-p && rmdir ./-p as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -6450,13 +5242,19 @@ as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 -# Save the log message, to keep $[0] and so on meaningful, and to +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" This file was extended by m6809-run $as_me 0.92, which was -generated by GNU Autoconf 2.63. Invocation command line was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -6488,13 +5286,15 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 ac_cs_usage="\ -\`$as_me' instantiates files from templates according to the -current configuration. +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. -Usage: $0 [OPTION]... [FILE]... +Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -6513,16 +5313,17 @@ $config_headers Configuration commands: $config_commands -Report bugs to ." +Report bugs to ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ m6809-run config.status 0.92 -configured by $0, generated by GNU Autoconf 2.63, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" -Copyright (C) 2008 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -6539,11 +5340,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -6557,27 +5363,29 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac - CONFIG_FILES="$CONFIG_FILES '$ac_optarg'" + as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; --header | --heade | --head | --hea ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; esac - CONFIG_HEADERS="$CONFIG_HEADERS '$ac_optarg'" + as_fn_append CONFIG_HEADERS " '$ac_optarg'" ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - { $as_echo "$as_me: error: ambiguous option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; };; + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ @@ -6585,11 +5393,10 @@ Try \`$0 --help' for more information." >&2 ac_cs_silent=: ;; # This is an error. - -*) { $as_echo "$as_me: error: unrecognized option: $1 -Try \`$0 --help' for more information." >&2 - { (exit 1); exit 1; }; } ;; + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; - *) ac_config_targets="$ac_config_targets $1" + *) as_fn_append ac_config_targets " $1" ac_need_defaults=false ;; esac @@ -6606,7 +5413,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -6644,9 +5451,7 @@ do "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; - *) { { $as_echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 -$as_echo "$as_me: error: invalid argument: $ac_config_target" >&2;} - { (exit 1); exit 1; }; };; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -6669,26 +5474,24 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 - trap '{ (exit 1); exit 1; }' 1 2 13 15 + trap 'as_fn_exit 1' 1 2 13 15 } # Create a (secure) tmp directory for tmp files. { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || -{ - $as_echo "$as_me: cannot create a temporary directory in ." >&2 - { (exit 1); exit 1; } -} +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -6696,7 +5499,13 @@ $debug || if test -n "$CONFIG_FILES"; then -ac_cr=' ' +ac_cr=`echo X | tr X '\015'` +# On cygwin, bash can eat \r inside `` if the user requested igncr. +# But we know of no other shell where ac_cr would be empty at this +# point, so we can use a bashism as a fallback. +if test "x$ac_cr" = x; then + eval ac_cr=\$\'\\r\' +fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' /dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then ac_cs_awk_cr='\\r' @@ -6704,7 +5513,7 @@ else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -6713,24 +5522,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -6738,7 +5541,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -6752,7 +5555,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -6766,7 +5569,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -6786,7 +5589,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -6818,23 +5621,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || { { $as_echo "$as_me:$LINENO: error: could not setup config files machinery" >&5 -$as_echo "$as_me: error: could not setup config files machinery" >&2;} - { (exit 1); exit 1; }; } +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -6846,7 +5655,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -6858,13 +5667,11 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then - { { $as_echo "$as_me:$LINENO: error: could not make $CONFIG_HEADERS" >&5 -$as_echo "$as_me: error: could not make $CONFIG_HEADERS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -6949,9 +5756,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - { { $as_echo "$as_me:$LINENO: error: could not setup config headers machinery" >&5 -$as_echo "$as_me: error: could not setup config headers machinery" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -6964,9 +5769,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) { { $as_echo "$as_me:$LINENO: error: invalid tag $ac_tag" >&5 -$as_echo "$as_me: error: invalid tag $ac_tag" >&2;} - { (exit 1); exit 1; }; };; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -6985,7 +5788,7 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -6994,12 +5797,10 @@ $as_echo "$as_me: error: invalid tag $ac_tag" >&2;} [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - { { $as_echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 -$as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} - { (exit 1); exit 1; }; };; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac - ac_file_inputs="$ac_file_inputs '$ac_f'" + as_fn_append ac_file_inputs " '$ac_f'" done # Let's still pretend it is `configure' which instantiates (i.e., don't @@ -7010,7 +5811,7 @@ $as_echo "$as_me: error: cannot find input file: $ac_f" >&2;} `' by configure.' if test x"$ac_file" != x-; then configure_input="$ac_file. $configure_input" - { $as_echo "$as_me:$LINENO: creating $ac_file" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 $as_echo "$as_me: creating $ac_file" >&6;} fi # Neutralize special characters interpreted by sed in replacement strings. @@ -7022,10 +5823,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -7053,47 +5852,7 @@ $as_echo X"$ac_file" | q } s/.*/./; q'` - { as_dir="$ac_dir" - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir="$ac_dir"; as_fn_mkdir_p ac_builddir=. case "$ac_dir" in @@ -7145,7 +5904,6 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # If the template does not know about datarootdir, expand it. # FIXME: This hack should be removed a few years after 2.60. ac_datarootdir_hack=; ac_datarootdir_seen= - ac_sed_dataroot=' /datarootdir/ { p @@ -7155,12 +5913,11 @@ ac_sed_dataroot=' /@docdir@/p /@infodir@/p /@localedir@/p -/@mandir@/p -' +/@mandir@/p' case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in *datarootdir*) ac_datarootdir_seen=yes;; *@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*) - { $as_echo "$as_me:$LINENO: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5 $as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;} _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 @@ -7170,7 +5927,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 s&@infodir@&$infodir&g s&@localedir@&$localedir&g s&@mandir@&$mandir&g - s&\\\${datarootdir}&$datarootdir&g' ;; + s&\\\${datarootdir}&$datarootdir&g' ;; esac _ACEOF @@ -7197,27 +5954,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && - { $as_echo "$as_me:$LINENO: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -7226,27 +5980,21 @@ $as_echo "$as_me: error: could not create $ac_file" >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then - { $as_echo "$as_me:$LINENO: $ac_file is unchanged" >&5 + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || { { $as_echo "$as_me:$LINENO: error: could not create $ac_file" >&5 -$as_echo "$as_me: error: could not create $ac_file" >&2;} - { (exit 1); exit 1; }; } + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || { { $as_echo "$as_me:$LINENO: error: could not create -" >&5 -$as_echo "$as_me: error: could not create -" >&2;} - { (exit 1); exit 1; }; } + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi # Compute "$ac_file"'s index in $config_headers. _am_stamp_count=1 @@ -7283,7 +6031,7 @@ $as_echo X"$ac_file" | s/.*/./; q'`/stamp-h$_am_stamp_count ;; - :C) { $as_echo "$as_me:$LINENO: executing $ac_file commands" >&5 + :C) { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5 $as_echo "$as_me: executing $ac_file commands" >&6;} ;; esac @@ -7367,47 +6115,7 @@ $as_echo X"$file" | q } s/.*/./; q'` - { as_dir=$dirpart/$fdir - case $as_dir in #( - -*) as_dir=./$as_dir;; - esac - test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { - as_dirs= - while :; do - case $as_dir in #( - *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( - *) as_qdir=$as_dir;; - esac - as_dirs="'$as_qdir' $as_dirs" - as_dir=`$as_dirname -- "$as_dir" || -$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ - X"$as_dir" : 'X\(//\)[^/]' \| \ - X"$as_dir" : 'X\(//\)$' \| \ - X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || -$as_echo X"$as_dir" | - sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ - s//\1/ - q - } - /^X\(\/\/\)[^/].*/{ - s//\1/ - q - } - /^X\(\/\/\)$/{ - s//\1/ - q - } - /^X\(\/\).*/{ - s//\1/ - q - } - s/.*/./; q'` - test -d "$as_dir" && break - done - test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || { { $as_echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 -$as_echo "$as_me: error: cannot create directory $as_dir" >&2;} - { (exit 1); exit 1; }; }; } + as_dir=$dirpart/$fdir; as_fn_mkdir_p # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done @@ -7418,15 +6126,12 @@ done done # for ac_tag -{ (exit 0); exit 0; } +as_fn_exit 0 _ACEOF -chmod +x $CONFIG_STATUS ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - { { $as_echo "$as_me:$LINENO: error: write failure creating $CONFIG_STATUS" >&5 -$as_echo "$as_me: error: write failure creating $CONFIG_STATUS" >&2;} - { (exit 1); exit 1; }; } + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -7447,10 +6152,10 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || { (exit 1); exit 1; } + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then - { $as_echo "$as_me:$LINENO: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi diff --git a/machine.c b/machine.c index e308dd8..195053e 100644 --- a/machine.c +++ b/machine.c @@ -59,6 +59,7 @@ void do_fault (unsigned int addr, unsigned int type) machine->fault (addr, type); } +// nac never used. void exit_fault (unsigned int addr, unsigned int type) { monitor_on = debug_enabled; @@ -188,9 +189,53 @@ absolute_address_t absolute_from_reladdr (unsigned int device, unsigned long rel U8 abs_read8 (absolute_address_t addr) { - unsigned int id = addr >> 28; - unsigned long phy_addr = addr & 0xFFFFFFF; - struct hw_device *dev = device_table[id]; + // nac come here on dbg examine. Core dump on access to nxm. + // nac what is "id" and how is it extracted from top 4 bits and + // why does this need addr to be 64 bits? + unsigned int id = addr >> 28; + unsigned long phy_addr = addr & 0xFFFFFFF; + // printf("In abs_read8 with address 0x%x, id 0x%x and phy_addr 0x%x\n",addr,id,phy_addr); + // nac BUG! should not be doing this directly: + // an attempt to access a non-existent location (a location whose device ID is FF) + // results in an attempt to access a non-existent value in the device_table. + // Actually it's doubly bad: there are 32 devices (max) but access to non-existent + // device seems to yield an ID of 0xf rather than 0xff which, based on the 28-bit + // shift, implies that the address was bad in the first place: it only had f instead of ff + // In any case, the table should not be indexed with f or ff becasue neither are valid + // devices. + // BUT! my "fix" below is bad; the fault gets reported 2ce and + // the data value gets reported as a 32-bit value instead of a U8 + // eg, if null_read is set up to return 0xab it returns 0xffffffab + // and if it's set up to return 0x3b it returns 0x3b -- ie, it is + // being sign extended. Not sure why, though, becasue it looks identical + // to the normal read; must be due to a path taken in the error handling? + // + // 2 scenarios: access to 0:0 ie direct access device 0 even though + // that device is not mapped into the bus anywhere. Currently does not + // report any error but does return 0xffffffff (sign extended). Not reporting an error + // is fine (I suppose) because the access is not really being checked + // -- it doesn't correspond to a CPU address. + // Other scenario is access to 0x7c80 in smii. This is a real CPU + // address but is mapped to a non-existent device. Currently get 2 + // errors reported: the first is due to an access through cpu_read8 + // and the error is a page fault, address 0x7c80 -- the error is + // triggered by a check of the map entry. The second is due + // to an access through abs_read8 and the error is a page fault, + // address 0xf000.0000 -- thinks it's device 0xff but truncated. + // For this one the data comes back as 0xffffffff (sign-extended). + // + // Maybe need to switch to using CPU addresses everywhere user-facing + // and allow device:offset addressing only on the command line? + // + // Another option that might help a fix is to switch to initialising + // the map with device 0 rather than with non-such-device. Then, + // no-such-device can be a more fatal error... + + // orig: -- core dumps!! + //struct hw_device *dev = device_table[id]; + // replacement: -- still not right. + struct hw_device *dev = find_device (addr, id); + struct hw_class *class_ptr = dev->class_ptr; return (*class_ptr->read) (dev, phy_addr); } @@ -235,6 +280,7 @@ U16 cpu_read16 (unsigned int addr) */ void cpu_write8 (unsigned int addr, U8 val) { + //printf("write 0x%04x<-0x%02x\n", addr, val); struct bus_map *map = find_map (addr); struct hw_device *dev = find_device (addr, map->devid); struct hw_class *class_ptr = dev->class_ptr; @@ -298,7 +344,7 @@ void dump_machine (void) printf("Device %2d: %s\n",devno, device_table[devno]->class_ptr->name); } - /* Mapping */ + /* mapping */ for (mapno = 0; mapno < NUM_BUS_MAPS; mapno++) { struct bus_map *map = &busmaps[mapno]; @@ -317,12 +363,7 @@ void dump_machine (void) dot_dot = 0; printf ("Map %3d: addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n", mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset, - 0 /* device_table[map->devid]->size */, map->flags); -#if 0 - for (n = 0; n < BUS_MAP_SIZE; n++) - printf ("%02X ", cpu_read8 (mapno * BUS_MAP_SIZE + n)); - printf ("\n"); -#endif + device_table[map->devid]->size, map->flags); } /* ready for next time */ prev_devid = map->devid; diff --git a/monitor.c b/monitor.c index 3071ace..b756630 100644 --- a/monitor.c +++ b/monitor.c @@ -1082,6 +1082,7 @@ int sizeof_file(FILE * file) return size; } +// nac it would be nice to have an intelligent map file reader.. int load_map_file (const char *name) { FILE *fp; From 864d37aad3bf0b85267df41e8bbdc8da3ab7cda5 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 23 Jun 2015 15:52:42 +0100 Subject: [PATCH 27/71] notes on exec09 internals inferred from code inspection. --- internals.txt | 174 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 internals.txt diff --git a/internals.txt b/internals.txt new file mode 100644 index 0000000..a08ff90 --- /dev/null +++ b/internals.txt @@ -0,0 +1,174 @@ +Introduction +------------ + +exec09 has several pre-defined "machines" and it is quite easy to +define new ones. + +The 6809 processor can access a 16-bit address space and defining a +machine involves defining what is in the address space. + +The address space is populated by a set of "devices". Consider the +imaginary machine foo. The machine is initialised by foo_init() and +that routine contains a series of calls to device_define(). + +Each device is an instance of a certain "class". There are pre-defined +classes for RAM, ROM, console-io and some others. + +Address decoding +---------------- + +The 16-bit address space is divided into regions of size +BUS_MAP_SIZE. This is 128 by default, meaning that the address space +is divided into 512 pieces each of which is described by a struct bus_map. + +There is an array (busmaps[]) of struct bus_map. For a particular +memory access, the array is indexed by the top 9 bits of the 16-bit +address. + +This description will start by considering the simple case, and move +on to describe ways to handle more complex situations. + +Ignore I/O for the moment and consider that our imaginary machine foos +is populated with RAM from 0-0x3ff and a ROM from 0xe000-0xfff. + +The machine initialisation, foo_init, will: + +- create, attach and initialise the RAM device +- create, attach and initialise the ROM device +- map the RAM device +- map the ROM device. + +Creating the device allocates storage to it. Attaching the device (to +the bus) assigns an ordinal number, "devid" to the device which is used +as its index in the device_table[]. The device_table stores hw_device +struct. + +Mapping the device involves populating entries in busmaps[]. After +reset, each entry in busmaps[] references a device of class +null_class. This is responsible for generating non-existent memory +exception in response to a read or write (this also means that the +address space read/write routines don't need to do any check of +address parameters or return values). + +Our 1kbyte RAM mapped at address 0 will occupy 1024/128=8 locations in +busmaps[]; busmaps[0]..busmaps[7] will each map to different offsets +in the same device. + +bus_map() (called by device_define()) stores the devid, offset and +flags in each of the busmaps[] entries. + +One of the final steps in machine initialisation is to make a copy of +busmaps[] into default_busmaps[]. During run-time, it is possible to +call bus_map() again to change the mapping of an address region or to +call bus_unmap() to restore the mapping of an address region to its +original start-up value. + +TODO bus_unmap is a bad name, and it is not used anywhere. + +TODO the null device is created automatically but not used +automatically. Instead, value 0xFF means unmapped. + +Special address decoding 1: windowing +------------------------------------- + +In the simple case, a device will be fully mapped into a region of the +16-bit CPU address space. However, this need not be the +case. device_define() takes arguments "offset", "addr", "len". This +allows a sub-set of a device (a window of size "len") to be exposed in +the CPU address space starting at address "addr". The CPU address +"addr" will correspond to offset "offset" from the start of storage +provided by the device. + +The intention here is that a machine will implement control registers +that can control the window (eg, an I/O device that supplies modified +value of "offset"). Each map entry (ie, each 128-byte region) has its +own independent value of "offset" and so there can be an arbitrary +remapping on 128-byte boundaries. + +Special address decoding 2: simple overlay +------------------------------------------ + +If you make multiple calls to device_define() with overlapping address +assignments, the later calls will overwrite the earlier ones. You can +take advantage of this to "carve a hole" in the address space of a +large device in order to insert a small device -- provided that device +occupies a multiple of 128 locations. For example, a ROM at the top +of the address space but with a device defined over the top of it to +carve a hole from 0xff00-0xff7f for I/O devices, but still providing +ROM at 0xff80-0xffff (for the exception vectors). In this case, simply +define the I/O device after the ROM device. + +Special address decoding 3: io expander +--------------------------------------- + +Sometimes, 128 locations (the default minimum resolution of address +space decode) is too coarse. One way to make efficient use of it is to +use a device of class ioexpand_class. This breaks a 128-byte region +into 16, 8-byte "slots" each of which can be associated with a +different device. + +It's also possible to map slots to ROM and RAM devices so that a +device can "carve a hole" of 8 bytes in a ROM or RAM. Look at the +definition of multicomp09 to see an example of this. + +TODO restriction: implementation in sparse_io only allows 1 busmap[] +entry, ie it is restricted to an address range of BUS_MAP_SIZE (128 +bytes). + +TODO code and add an example. + +TODO note that, using ioexpand, the ioexpander itself needs to have +permissive access. Is the access of the lower-level device honoured? +Access check seems to work in two ways: first the map access is +checked an then (maybe) the device iteself checks access. That seems a +bit messy. + +Image Loading +------------- + +When exec09 starts up, the memory is empty. You can use a command-line +argument to pre-load an image to memory. + +You can load an image in binary format, s-record format in intel-hex +format. The command-line default is to load an s-record file (TODO +there may be no way to specify a hex file currently even though all +the code is in place to allow it). + +s-record and intel-hex files contain addressing information and so +they can write to arbitrary (and potentially non-contiguous) regions +of address space. When data is loaded in one of these file formats: + +- it is loaded after the machine has been initialised +- it is written to memory byte-by-byte as though by the 6809 CPU + (the 16-bit address space is exactly as seen by the CPU). +- any attempt to write to non-existent or non-writeable memory will + result in an access violation being reported. + +To load a binary file it must be specified using the "-b" command-line +option. You can only load a binary file if your machine contains a ROM +device and (unless you have coded your machine specifically) you can +only load a single ROM device. + +Unlike an s-record or intel-hex file, a binary file is loaded as part +of machine initialisation and is loaded directly by the ROM +device. There are no access checks: the device is loaded even if it is +normally read-only. Since a binary file contains no addressing +information it is loaded to incrementing byte locations starting at +offset 0 in the ROM device; in fact, the ROM device is created to be +of the exact size needed to hold the binary image; this may be +smaller, larger or identical in size to the space assigned to the ROM +device in the machine's address space. + +TODO how does an s-rec file load to ROM if, as I stated above, the +normal access checks occur? (maybe it doesn't, since I did my "bug fix") + +TODO if, as I explained above, a ROM is exactly the size of its +binary, how can the ROM exist other than when pre-loaded from an image +(but I know that it can be loaded from srec..). + + + + +NEXT + +different/wider address spaces, why what for and how. From d03904d3c9abcffd4a4046f556d40a4b48eb0ea5 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sat, 4 Jul 2015 19:47:32 +0100 Subject: [PATCH 28/71] Add infrastructure to allow a machine to have a dump() function that is invoked (if it exists) by the previously unimplemented du command. --- command.c | 4 ++-- machine.c | 14 +++++++++++++- machine.h | 1 + miscsbc.c | 30 +++++++++++++++++++++++++----- 4 files changed, 41 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index 70bb2c8..481a303 100644 --- a/command.c +++ b/command.c @@ -1042,7 +1042,7 @@ void cmd_trace_dump (void) void cmd_dump (void) { - printf("not implemented\n"); + dump_machine(); } void cmd_restore (void) @@ -1052,7 +1052,7 @@ void cmd_restore (void) void cmd_info (void) { - dump_machine(); + describe_machine(); } /****************** Parser ************************/ diff --git a/machine.c b/machine.c index 195053e..138fe35 100644 --- a/machine.c +++ b/machine.c @@ -325,8 +325,20 @@ absolute_address_t to_absolute (unsigned long cpuaddr) return absolute_from_reladdr (map->devid, phy_addr); } + +// Dump machine (if supported) +void dump_machine(void) +{ + if (machine->dump) { + machine->dump(); + } + else { + printf("This machine does not provide a dump capability\n"); + } +} + // Describe machine, devices and mapping. -void dump_machine (void) +void describe_machine (void) { unsigned int devno; unsigned int mapno; diff --git a/machine.h b/machine.h index 44c1946..05437d9 100644 --- a/machine.h +++ b/machine.h @@ -145,6 +145,7 @@ struct machine void (*fault) (unsigned int addr, unsigned char type); void (*dump_thread) (unsigned int thread_id); void (*periodic) (void); + void (*dump) (void); unsigned long cycles_per_sec; }; diff --git a/miscsbc.c b/miscsbc.c index 3f083e0..4e39d1d 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -9,6 +9,7 @@ int smii_i_avail = 1; int smii_o_busy = 0; // for multicomp09 sdmapper +#define MULTICOMP09_RAMMAX (0x20000) char mc_protect = 0x00; char mc_romdis = 0x00; char mc_mapper = 0x76; @@ -20,11 +21,13 @@ int mc_addr; int mc_state; int mc_poll; int mc_dindex; -FILE *sd_file; // [NAC HACK 2015May07] to allow remap of io. Really nasty hack. +// [NAC HACK 2015May07] also needed to allow dump. struct hw_device *mc_rom, *mc_ram, *mc_iodev; +FILE *sd_file; FILE *batch_file; +FILE *dump_file; /******************************************************************** * The Scroungemaster II machine, a platform @@ -181,7 +184,7 @@ struct machine smii_machine = /******************************************************************** * The Multicomp 6809 machine, a platform for Dragon BASIC. - * This version has 1 serial port, 56K RAM and 8K ROM, SDCARD if + * This version has 1 serial port, 56K RAM and 8K ROM, SDCARD i/f. * The serial port is in a "hole" at 0xFFD0/0xFFD1 * See: * Grant Searle http://searle.hostei.com/grant/Multicomp/index.html @@ -551,7 +554,7 @@ void multicomp09_init (const char *boot_rom_file) windows into any of the 16, 8K chunks via the mc_mapping register. */ - ramdev = ram_create(0x20000); + ramdev = ram_create(MULTICOMP09_RAMMAX); /* ROM is 8Kbytes. Usually sits from E000 to FFFF but can be disabled by writing 1 to mc_romdis. @@ -603,7 +606,7 @@ void multicomp09_init (const char *boot_rom_file) mc_ram = ramdev; mc_iodev = iodev; - /* Now map all the devices into he address space, in accordance + /* Now map all the devices into the address space, in accordance with the settings of the memory mapper. */ sdmapper_remap(); @@ -626,11 +629,28 @@ void multicomp09_init (const char *boot_rom_file) } +/* Dump just does a binary dump of the RAM space. Properly it should also dump + the memory mapper state. The dump is only intended to aid debug/analysis. To + be used for (eg) persistence there's lots more state that would be needed. +*/ +void multicomp09_dump (void) +{ + int i; + char byte; + dump_file = file_open(NULL, "multicomp09.dmp", "w+b"); + for (i=0; i Date: Wed, 8 Jul 2015 23:18:38 +0100 Subject: [PATCH 29/71] Modified multicomp to use model of mk2 memory mapper. Will not currently start up properly using .hex files as they load over the I/O and corrupt it. Works OK with .bin files. Problem with .hex files will be fixed by defining a "startup" phase when they are loaded. Lots of nasty hacks in this code at the moment; need to think through some proper fixes to the problems exposed here. --- miscsbc.c | 176 +++++++++++++++++++++++++++++++++++------------------- 1 file changed, 116 insertions(+), 60 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 4e39d1d..11c1b75 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -8,11 +8,12 @@ int smii_i_avail = 1; int smii_o_busy = 0; -// for multicomp09 sdmapper +// for multicomp09 sdmapper: values most-recently written to these registers #define MULTICOMP09_RAMMAX (0x20000) -char mc_protect = 0x00; -char mc_romdis = 0x00; -char mc_mapper = 0x76; +unsigned char mc_mmuadr = 0x00; +unsigned char mc_mmudat = 0x00; +unsigned char mc_timer = 0x00; +unsigned char mc_pblk[16]; // [7] is protect, [6:0] is physical block unsigned char mc_sdlba2; // because we're doing maths on them unsigned char mc_sdlba1; unsigned char mc_sdlba0; @@ -27,6 +28,7 @@ struct hw_device *mc_rom, *mc_ram, *mc_iodev; FILE *sd_file; FILE *batch_file; +FILE *log_file; FILE *dump_file; /******************************************************************** @@ -60,7 +62,7 @@ U8 smii_console_read (struct hw_device *dev, unsigned long addr) if (ch == 10) ch = 13; //cr return ch; default: - printf("In smii_console_read with addr=0x%08x\n", addr); + printf("In smii_console_read with addr=0x%08x\n", (unsigned int)addr); return 0x42; } } @@ -79,7 +81,7 @@ void smii_console_write (struct hw_device *dev, unsigned long addr, U8 val) putchar(val); break; default: - printf("In smii_console_write with addr=0x%08x val=0x%02x\n",addr, val); + printf("In smii_console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); } } @@ -211,16 +213,17 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) if (ch == 10) return 13; // LF->CR return ch; default: - printf("In console_read with addr=0x%08x\n", addr); + printf("In console_read with addr=0x%08x\n", (unsigned int)addr); return 0x42; } } void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 val) { + fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { case 0: - printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); + printf("In console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); break; case 1: @@ -231,14 +234,47 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va break; default: - printf("In console_write with addr=0x%08x val=0x%02x\n",addr, val); + printf("In console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); } } +// given a physical block number (0-7) return the offset into physical memory +int mmu_offset(int blk) { + int tmp; + int idx; + if (mc_mmuadr & 0x20) { + // mmu enabled + // 0-7 if tr=0, 8-15 if tr=1 + idx = blk | ((mc_mmuadr & 0x40) >> 3); + tmp = mc_pblk[idx]; + return (tmp & 0x7f) << 13; + } + else { + return blk << 13; + } +} + +// given a physical block number (0-7) return the flags +int mmu_flags(int blk) { + int tmp; + int idx; + if (mc_mmuadr & 0x20) { + // mmu enabled + // 0-7 if tr=0, 8-15 if tr=1 + idx = blk | ((mc_mmuadr & 0x40) >> 3); + tmp = mc_pblk[idx]; + return (tmp >> 7) == 1 ? MAP_READABLE : MAP_READWRITE; + } + else { + return MAP_READWRITE; + } +} + + /* SDCARD and memory mapper - FFDF SDCARD MAPPER wo remaps 2 RAM windows - FFDE SDCARD ROMDIS wo bit 0 disables ROM when 1 - FFDD SDCARD PROTECT wo write protect in resolution of 8KByte + FFDF SDCARD MMUDAT wo + FFDE SDCARD MMUADR wo + FFDD SDCARD TIMER rw FFDC SDCARD SDLBA2 wo FFDB SDCARD SDLBA1 wo FFDA SDCARD SDLBA0 wo @@ -277,41 +313,35 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va error if too much data written or read or if command while not idle. */ -// Use values of mc_protect, mc_romdis, mc_mapper to set up address mappings. -void sdmapper_remap() +void sdmapper_remap(int update_table) { int i; - //[NAC HACK 2015May06] Yeuch. Horrible how I have had to hardwire the device numbers. - //overall, it would be better if I could pick them in the first place. + if (update_table) { + // MMUDAT write, so update appropriate mapping register + mc_pblk[mc_mmuadr & 0xf] = mc_mmudat; + } - // addr dev offset len flags - - // 0x0000-0x1FFF always direct mapped to RAM - bus_map(0x0000, 1, 0x0000, 0x2000, (mc_protect & 1) ? MAP_READABLE : MAP_READWRITE); - - // 0x2000-0x3FFF always direct mapped to RAM - bus_map(0x2000, 1, 0x2000, 0x2000, (mc_protect & 2) ? MAP_READABLE : MAP_READWRITE); - - // 0x4000-0x5FFF always direct mapped to RAM - bus_map(0x4000, 1, 0x4000, 0x2000, (mc_protect & 4) ? MAP_READABLE : MAP_READWRITE); + // now update mapping based on mc_mmuadr, mc_pblk[] - // 0x6000-0x7FFF always direct mapped to RAM - bus_map(0x6000, 1, 0x6000, 0x2000, (mc_protect & 8) ? MAP_READABLE : MAP_READWRITE); + //[NAC HACK 2015May06] Yeuch. Horrible how I have had to hardwire the device numbers. + //overall, it would be better if I could pick them in the first place. - // 0x8000-0x9FFF always direct mapped to RAM - bus_map(0x8000, 1, 0x8000, 0x2000, (mc_protect & 16) ? MAP_READABLE : MAP_READWRITE); - // 0xA000-0xBFFF always direct mapped to RAM - bus_map(0xA000, 1, 0xA000, 0x2000, (mc_protect & 32) ? MAP_READABLE : MAP_READWRITE); + // addr dev offset len flags - // 0xC000-0xDFFF remappable RAM - bus_map(0xC000, 1, (mc_mapper & 0xf)<<13, 0x2000, (mc_protect & 64) ? MAP_READABLE : MAP_READWRITE); + bus_map(0x0000, 1, mmu_offset(0), 0x2000, mmu_flags(0)); + bus_map(0x2000, 1, mmu_offset(1), 0x2000, mmu_flags(1)); + bus_map(0x4000, 1, mmu_offset(2), 0x2000, mmu_flags(2)); + bus_map(0x6000, 1, mmu_offset(3), 0x2000, mmu_flags(3)); + bus_map(0x8000, 1, mmu_offset(4), 0x2000, mmu_flags(4)); + bus_map(0xA000, 1, mmu_offset(5), 0x2000, mmu_flags(5)); + bus_map(0xC000, 1, mmu_offset(6), 0x2000, mmu_flags(6)); // 0xE000-0xFFFF ROM or remappable RAM - if (mc_romdis & 1) { - // ROM disabled; map RAM - bus_map(0xE000, 1, (mc_mapper & 0xf0)<<9, 0x2000, (mc_protect & 128) ? MAP_READABLE : MAP_READWRITE); + if (mc_mmuadr & 0x80) { + // ROM disabled; map RAM. + bus_map(0xE000, 1, mmu_offset(7), 0x2000, mmu_flags(7)); } else { // ROM @@ -333,9 +363,11 @@ void sdmapper_remap() // bus address of the location. // Access permission inherited from underlying // device, which is exactly what I want. - if (mc_romdis) { - // RAM. Offset is a function of paging register - ioexpand_attach(mc_iodev, i, ((mc_mapper & 0xf0)<<9) + 0x1F80 + (i*8), mc_ram); + if (mc_mmuadr & 0x80) { + // ROM is disabled; map RAM. Offset is a function of paging register + // [NAC HACK 2015Jun26] was: + // ioexpand_attach(mc_iodev, i, ((mc_mapper & 0xf0)<<9) + 0x1F80 + (i*8), mc_ram); + ioexpand_attach(mc_iodev, i, mmu_offset(7) + 0x1F80 + (i*8), mc_ram); } else { // ROM @@ -354,6 +386,7 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) case 0: // SDDATA switch (mc_state) { case 0: case 1: case 2: + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; case 3: // in read if (mc_poll == 3) { @@ -362,19 +395,23 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) mc_state = 2; // final read then back to idle } if (mc_dindex < 512) { + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_data[mc_dindex]); return mc_data[mc_dindex++]; } else { printf("ERROR attempt to read too much data from sd block\n"); + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; } } else { printf("ERROR attempt to read sd block when data not yet available\n"); + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; } case 4: // in write printf("ERROR attempt to read sd data during write command\n"); + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; } break; // unreachable @@ -382,32 +419,47 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) switch (mc_state) { case 0: // busy and always will remain so + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x90); return 0x90; case 1: // count polls and initialise mc_poll++; if (mc_poll == 16) mc_state = 2; + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x90); return 0x90; case 2: // idle. + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x80); return 0x80; case 3: // in read if (mc_poll < 3) mc_poll++; - if (mc_poll == 3) + if (mc_poll == 3) { + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xe0); return 0xe0; // data available - else + } + else { + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xa0); return 0xa0; // still waiting TODO maybe 20 + } case 4: // in write if (mc_poll < 3) mc_poll++; - if (mc_poll == 3) + if (mc_poll == 3) { + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xa0); return 0xa0; // space available - else + } + else { + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x20); return 0x20; // still waiting + } } break; // unreachable + case 5: // TIMER + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_timer); + return mc_timer; default: - printf("INFO In sdmapper_read with addr=0x%08x\n", addr); + printf("INFO In sdmapper_read with addr=0x%08x\n", (unsigned char)addr); + fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x42); return 0x42; } } @@ -417,6 +469,7 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) { int retvar; //printf("INFO In sdmapper_write with addr=0x%08x, mc_state=%d mc_poll=%d mc_dindex=%d\n", addr, mc_state, mc_poll, mc_dindex); + fprintf(log_file,"%02x>%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { case 0: // SDDATA switch (mc_state) { @@ -503,17 +556,16 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) case 4: // SDLBA2 mc_sdlba2 = val; break; - case 5: // PROTECT - mc_protect = val; - sdmapper_remap(); + case 5: // TIMER + mc_timer = val; break; - case 6: // ROMDIS - mc_romdis = val; - sdmapper_remap(); + case 6: // MMUADR + mc_mmuadr = val; + sdmapper_remap(0); // 0=> remap memory based on mc_mmuadr break; - case 7: // MAPPER - mc_mapper = val; - sdmapper_remap(); + case 7: // MMUDAT + mc_mmudat = val; + sdmapper_remap(1); // 1=> update mc_pblk[] then remap memory based on mc_mmuadr break; } } @@ -549,15 +601,14 @@ void multicomp09_init (const char *boot_rom_file) struct hw_device* romdev; int i; - /* RAM is 128Kbytes. Low 6, 8K chunks are always mapped into - the address space. The upper 2, 8K chunks (CD, EF) are - windows into any of the 16, 8K chunks via the mc_mapping - register. + /* RAM is 128Kbytes. With MMU disabled low 64K is mapped linearly + otherwise, it is mapped in 8K chunks. Each chunk has a separate + write protect. */ ramdev = ram_create(MULTICOMP09_RAMMAX); /* ROM is 8Kbytes. Usually sits from E000 to FFFF but can be disabled - by writing 1 to mc_romdis. + by writing 0x80 to MMUADR */ romdev = rom_create (boot_rom_file, 0x2000); @@ -609,7 +660,7 @@ void multicomp09_init (const char *boot_rom_file) /* Now map all the devices into the address space, in accordance with the settings of the memory mapper. */ - sdmapper_remap(); + sdmapper_remap(0); /* If a file multicomp09.bat exists, supply input from it until @@ -626,6 +677,11 @@ void multicomp09_init (const char *boot_rom_file) mc_state = 1; else mc_state = 0; + /* + log file + */ + log_file = file_open(NULL, "multicomp09.log", "w+b"); + fprintf(log_file, "===Log file\n"); } From 512c0d44f6ebae69d7f00ece54040d529517e53d Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sat, 19 Sep 2015 17:10:12 +0100 Subject: [PATCH 30/71] Add simple support for a kipper1 target machine. --- README | 2 + machine.c | 2 + miscsbc.c | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/README b/README index 376cbc7..6f8e4c3 100644 --- a/README +++ b/README @@ -68,6 +68,8 @@ that wants to have persistence. * 'smii' - see miscsbc.c for details +* 'kipper1' - see miscsbc.c for details + TODO : Would anyone be interested in a CoCo machine type? ----------------------------------------------------------------- diff --git a/machine.c b/machine.c index 138fe35..2c7a9fa 100644 --- a/machine.c +++ b/machine.c @@ -664,6 +664,7 @@ void machine_init (const char *machine_name, const char *boot_rom_file) extern struct machine wpc_machine; extern struct machine smii_machine; extern struct machine multicomp09_machine; + extern struct machine kipper1_machine; int i; /* Initialize CPU maps, so that no CPU addresses map to @@ -679,6 +680,7 @@ void machine_init (const char *machine_name, const char *boot_rom_file) else if (machine_match (machine_name, boot_rom_file, &wpc_machine)); else if (machine_match (machine_name, boot_rom_file, &smii_machine)); else if (machine_match (machine_name, boot_rom_file, &multicomp09_machine)); + else if (machine_match (machine_name, boot_rom_file, &kipper1_machine)); else exit (1); /* Save the default busmap configuration, before the diff --git a/miscsbc.c b/miscsbc.c index 11c1b75..74ae3e5 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -197,11 +197,13 @@ struct machine smii_machine = */ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) { + //printf("In console_read with addr=0x%08x pc=0x%04x\n", (unsigned int)addr, get_pc()); unsigned char ch; switch (addr) { case 00: // status bit - return 0xff; + // hardware supports bits [7], [1], [0] + return 0x03; case 01: if (batch_file && fread( &ch, 1, 1, batch_file)) { } @@ -220,6 +222,7 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 val) { + //printf("In console_write with addr=0x%08x val=0x%02x pc=0x%04x\n", (unsigned int)addr, val, get_pc()); fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { case 0: @@ -710,3 +713,113 @@ struct machine multicomp09_machine = .periodic = 0, .dump = multicomp09_dump, }; + + +/******************************************************************** + * The kipper1 SBC + * + * 32KByte of RAM at $0000 + * 6850 ACIA at $A000,$A001 + * 16KByte of ROM at $C000 + ********************************************************************/ + +/* UART-style console. Console input is blocking (but should not be) + */ +U8 kipper1_console_read (struct hw_device *dev, unsigned long addr) +{ + //printf("In console_read with addr=0x%08x pc=0x%04x\n", (unsigned int)addr, get_pc()); + unsigned char ch; + switch (addr) { + case 0: + // status bit + // hardware supports bits [7], [1], [0] + return 0x03; + case 1: + if (batch_file && fread( &ch, 1, 1, batch_file)) { + } + else { + ch = getchar(); + } + // key conversions to make keyboard look DOS-like + if (ch == 127) return 8; // rubout->backspace + if (ch == 10) return 13; // LF->CR + return ch; + default: + printf("In console_read with addr=0x%08x\n", (unsigned int)addr); + return 0x42; + } +} + +void kipper1_console_write (struct hw_device *dev, unsigned long addr, U8 val) +{ + //printf("In console_write with addr=0x%08x val=0x%02x pc=0x%04x\n", (unsigned int)addr, val, get_pc()); + //fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); + switch (addr) { + case 0: + printf("In console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); + break; + + case 1: + //if ((val != 0x0d) && (val != 0x20) && (val != 0x0a) && (val < '0')) { + // printf("Char 0x%02x", val); + //} + putchar(val); + break; + + default: + printf("In console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); + } +} + + +void kipper1_init (const char *boot_rom_file) +{ + struct hw_device *kipper1_console, *rom; + + /* 32K RAM from 0000 to 7FFF */ + device_define ( ram_create (0x8000), 0, + 0x0000, 0x8000, MAP_READWRITE ); + + /* 16K ROM from C000 to FFFF */ + rom = rom_create (boot_rom_file, 0x4000); + device_define (rom , 0, + 0xC000, 0x4000, MAP_READABLE); + + /* I/O console at A000 + * SCCACMD at 0xA000 + * SCCADTA at 0xA001 + */ + + // flag inch_avail + // counter outch_busy init 0 + + // on read from SCCACMD if inch_avail set bit 0. If outch_busy=0 set bit 2. + // if outch_busy!=0, increment it module 4 (ie, it counts up to 4 then stops at 0) + // + // on read from SCCADTA expect inch_avail to be true else fatal error. Return char. + // + // on write to SCCADTA expect outch_busy=0 else fatal error, increment outch_busy (to 1) + + kipper1_console = console_create(); + kipper1_console->class_ptr->read = kipper1_console_read; + kipper1_console->class_ptr->write = kipper1_console_write; + + device_define ( kipper1_console, 0, + 0xA000, BUS_MAP_SIZE, MAP_READWRITE ); + + + + /* If a file kipper1.bat exists, supply input from it until + it's exhausted. + */ + batch_file = file_open(NULL, "kipper1.bat", "rb"); +} + + +struct machine kipper1_machine = +{ + .name = "kipper1", + .fault = fault, + .init = kipper1_init, + .periodic = 0, +}; From 5be05cdf6c0aa4f755abf14634d7962aa686801b Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 2 Oct 2015 21:47:54 +0100 Subject: [PATCH 31/71] ignore writes to MMUADR bit 4 to give better match to latest RTL and allow partial debug of single-step hardware. --- miscsbc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 74ae3e5..2ac5690 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -563,8 +563,12 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) mc_timer = val; break; case 6: // MMUADR - mc_mmuadr = val; - sdmapper_remap(0); // 0=> remap memory based on mc_mmuadr + // ignore writes where bit(4) is set; this is the single-step/nmi control + // and it forces the other write data to be ignored + if ((val & 0x10) == 0) { + mc_mmuadr = val; + sdmapper_remap(0); // 0=> remap memory based on mc_mmuadr + } break; case 7: // MMUDAT mc_mmudat = val; From 97e9d237803f7fd7a2e01417af19a6a5a585973d Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Sun, 24 Apr 2016 20:37:54 +0100 Subject: [PATCH 32/71] Revise multicomp description to encompass 3 UARTs and the GPIO unit. Add limited support for the other UARTs and messages for the GPIO access. --- miscsbc.c | 44 +++++++++++++++++++++++++++++++++----------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 2ac5690..dd4c9c8 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -185,26 +185,35 @@ struct machine smii_machine = /******************************************************************** - * The Multicomp 6809 machine, a platform for Dragon BASIC. - * This version has 1 serial port, 56K RAM and 8K ROM, SDCARD i/f. - * The serial port is in a "hole" at 0xFFD0/0xFFD1 + * The Multicomp 6809 machine + * This version has 3 serial ports, 56K RAM and 8K ROM, SDCARD i/f. + * GPIO, memory-mapper and timer interrupt. + * The I/O is all at 0xFFD0-0xFFDF * See: * Grant Searle http://searle.hostei.com/grant/Multicomp/index.html + * and: + * https://www.retrobrewcomputers.org/doku.php?id=boards:sbc:multicomp:cycloneii-c:start * ********************************************************************/ /* UART-style console. Console input is blocking (but should not be) + offset 0,1 - 1st UART - virtual UART. Main console + offset 2,3 - 2nd UART + offset 4,5 - 3rd UART + offset 6,7 - GPIO unit */ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) { //printf("In console_read with addr=0x%08x pc=0x%04x\n", (unsigned int)addr, get_pc()); unsigned char ch; switch (addr) { - case 00: + case 0: + case 2: + case 4: // status bit // hardware supports bits [7], [1], [0] return 0x03; - case 01: + case 1: if (batch_file && fread( &ch, 1, 1, batch_file)) { } else { @@ -214,6 +223,10 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) if (ch == 127) return 8; // rubout->backspace if (ch == 10) return 13; // LF->CR return ch; + case 6: + case 7: + printf("[gpio rd addr=0x%08x]\n", (unsigned int)addr); + return 0x42; default: printf("In console_read with addr=0x%08x\n", (unsigned int)addr); return 0x42; @@ -226,14 +239,23 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { case 0: - printf("In console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); + case 2: + case 4: + if (val==3) { + printf("[uart%1d reset]", (unsigned int)(1 + addr>>1)); + } + else { + printf("[uart%1d status write of 0x%02x\n", (unsigned int)(1 + addr>>1), val); + } break; case 1: - //if ((val != 0x0d) && (val != 0x20) && (val != 0x0a) && (val < '0')) { - // printf("Char 0x%02x", val); - //} - putchar(val); + putchar(val); /* UART 1*/ + break; + + case 6: + case 7: + printf("[gpio wr addr=0x%08x val=0x%02x]\n", (unsigned int)addr, val); break; default: @@ -640,7 +662,7 @@ void multicomp09_init (const char *boot_rom_file) for (i=0; i<16; i++) { if (i==10) { - // 0xFFD0-0xFFD7 -- VDU and UART + // 0xFFD0-0xFFD7 -- VDU/UART and GPIO ioexpand_attach(iodev, i, 0, multicomp09_console); } else if (i==11) { From 32e36e3dcf190f5c01d6cb52fb6488d48c33010d Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 22 Jul 2016 23:14:50 +0100 Subject: [PATCH 33/71] needed to allow compile on some platforms. --- serial.c | 1 + 1 file changed, 1 insertion(+) diff --git a/serial.c b/serial.c index 7f56d8d..5773a42 100644 --- a/serial.c +++ b/serial.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include From dd76c39bd0de140632c1c6037f5c0ab8756b5b6f Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 22 Jul 2016 23:15:33 +0100 Subject: [PATCH 34/71] Replace map-file reader code with code that works for gcc/lwlink tool-chain. --- monitor.c | 45 +++++++++++++-------------------------------- 1 file changed, 13 insertions(+), 32 deletions(-) diff --git a/monitor.c b/monitor.c index b756630..1d94ef3 100644 --- a/monitor.c +++ b/monitor.c @@ -1088,7 +1088,7 @@ int load_map_file (const char *name) FILE *fp; char map_filename[256]; char buf[256]; - char *value_ptr, *id_ptr; + char *tok_ptr, *value_ptr, *id_ptr; target_addr_t value; char *file_ptr; struct symbol *sym = NULL; @@ -1121,39 +1121,20 @@ int load_map_file (const char *name) if (feof (fp)) break; - value_ptr = buf; - if (!strncmp (value_ptr, "page", 4)) - { - unsigned char page = (unsigned char) strtoul(value_ptr+4, NULL, 10); - if (!strcmp (machine->name, "wpc")) - wpc_set_rom_page (page); - sym = NULL; - continue; - } - - if (strncmp (value_ptr, " ", 6)) - continue; - - while (*value_ptr == ' ') - value_ptr++; - - value = (target_addr_t) strtoul(value_ptr, &id_ptr, 16); - if (id_ptr == value_ptr) - continue; - - while (*id_ptr == ' ') - id_ptr++; - - id_ptr = strtok (id_ptr, " \t\n"); - if (((*id_ptr == 'l') || (*id_ptr == 's')) && (id_ptr[1] == '_')) - continue; - ++id_ptr; + tok_ptr = strtok (buf, " \t\n"); + if (0 != strcmp(tok_ptr, "Symbol:")) + continue; - file_ptr = strtok (NULL, " \t\n"); + id_ptr = strtok(NULL, " \t\n"); + // skip over filename + tok_ptr = strtok (NULL, " \t\n"); + // skip over "=" + tok_ptr = strtok (NULL, " \t\n"); + value_ptr = strtok (NULL, " \t\n"); + // get value as hex string + value = (target_addr_t) strtoul(value_ptr, NULL, 16); - if (sym) - sym->ty.size = to_absolute (value) - sym->value; - sym = sym_add (&program_symtab, id_ptr, to_absolute (value), 0); /* file_ptr? */ + sym_add (&program_symtab, id_ptr, to_absolute (value), 0); } fclose (fp); From 4b47372653327012e8bc58dedfb6213ea62e41e6 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 22 Jul 2016 23:16:46 +0100 Subject: [PATCH 35/71] Fit formatting to remove tabs Various bug and consistency fixes: - Use upper case consistently for hex print - Mark watch-points correctly: previously they were sometimes getting converted to breakpoints because br->on_execute did not have a default value - Some paths through the watchpoint code were resulting in the watchpoint triggering but not being reported. - A set with no arguments used to core-dump. There's still some debug code in here while I get my head around the proper functioning of 'set'. --- command.c | 227 +++++++++++++++++++++++++++--------------------------- 1 file changed, 115 insertions(+), 112 deletions(-) diff --git a/command.c b/command.c index 481a303..e1ba931 100644 --- a/command.c +++ b/command.c @@ -184,13 +184,13 @@ void eval_assign (char *expr, unsigned long val) unsigned long target_read (absolute_address_t addr, unsigned int size) { - switch (size) - { - case 1: - return abs_read8 (addr); - case 2: - return abs_read16 (addr); - } + switch (size) + { + case 1: + return abs_read8 (addr); + case 2: + return abs_read16 (addr); + } } void parse_format_flag (const char *flags, unsigned char *formatp) @@ -199,6 +199,7 @@ void parse_format_flag (const char *flags, unsigned char *formatp) { switch (*flags) { + case 'X': case 'x': case 'd': case 'u': @@ -266,17 +267,17 @@ int fold_binary (char *expr, const char op, unsigned long *valp) return 0; *p++ = '\0'; - val1 = eval (expr); - val2 = eval (p); + val1 = eval (expr); + val2 = eval (p); - switch (op) - { - case '+': *valp = val1 + val2; break; - case '-': *valp = val1 - val2; break; - case '*': *valp = val1 * val2; break; - case '/': *valp = val1 / val2; break; - } - return 1; + switch (op) + { + case '+': *valp = val1 + val2; break; + case '-': *valp = val1 - val2; break; + case '*': *valp = val1 * val2; break; + case '/': *valp = val1 / val2; break; + } + return 1; } /** @@ -389,6 +390,7 @@ breakpoint_t* brkalloc (void) br->keep_running = 0; br->ignore_count = 0; br->temp = 0; + br->on_execute = 0; brk_enable (br, 1); return br; } @@ -454,7 +456,7 @@ void brkprint (breakpoint_t *brkpt) if (brkpt->ignore_count) printf (", ignore %d times\n", brkpt->ignore_count); if (brkpt->write_mask) - printf (", mask %02X\n", brkpt->write_mask); + printf (", mask 0x%02X\n", brkpt->write_mask); putchar ('\n'); } @@ -503,18 +505,19 @@ void print_value (unsigned long val, datatype_t *typep) break; } - if (typep->format == 'x') + if ((typep->format == 'x') | (typep->format == 'X')) { - printf ("0x"); + printf ("0x"); sprintf (f, "%%0%d%c", typep->size * 2, typep->format); } - else if (typep->format == 'o') + else if (typep->format == 'o') { - printf ("0"); + printf ("0"); sprintf (f, "%%%c", typep->format); } else sprintf (f, "%%%c", typep->format); + printf (f, val); } @@ -523,18 +526,18 @@ void display_print (void) unsigned int n; char comma = '\0'; - for (n = 0; n < MAX_DISPLAYS; n++) - { - display_t *ds = &displaytab[n]; - if (ds->used) - { + for (n = 0; n < MAX_DISPLAYS; n++) + { + display_t *ds = &displaytab[n]; + if (ds->used) + { char expr[256]; strcpy (expr, ds->expr); printf ("%c %s = ", comma, expr); print_value (eval (expr), &ds->type); comma = ','; - } - } + } + } if (comma) putchar ('\n'); @@ -542,45 +545,46 @@ void display_print (void) int print_insn (absolute_address_t addr) { - char buf[64]; - int size = dasm (buf, addr); - printf ("%s", buf); - return size; + char buf[64]; + int size = dasm (buf, addr); + printf ("%s", buf); + return size; } void do_examine (void) { unsigned int n; - unsigned int objs_per_line = 16; + unsigned int objs_per_line = 16; if (isdigit (*command_flags)) examine_repeat = strtoul (command_flags, &command_flags, 0); - if (*command_flags == 'i') - examine_type.format = *command_flags; - else + if (*command_flags == 'i') + examine_type.format = *command_flags; + else parse_format_flag (command_flags, &examine_type.format); + parse_size_flag (command_flags, &examine_type.size); - switch (examine_type.format) + switch (examine_type.format) { case 'i': - objs_per_line = 1; + objs_per_line = 1; break; case 'w': - objs_per_line = 8; + objs_per_line = 8; break; } for (n = 0; n < examine_repeat; n++) { - if ((n % objs_per_line) == 0) - { - putchar ('\n'); - print_addr (examine_addr); - printf (": "); - } + if ((n % objs_per_line) == 0) + { + putchar ('\n'); + print_addr (examine_addr); + printf (": "); + } switch (examine_type.format) { @@ -615,7 +619,8 @@ void do_print (char *expr) void do_set (char *expr) { - (void)eval (expr); + printf("In do_set with %s\n",expr); + (void)eval (expr); } /* TODO - WPC */ @@ -701,6 +706,8 @@ void cmd_set (void) { char *arg = getarg (); + if (!arg) + return; if (!strcmp (arg, "var")) arg = getarg (); @@ -761,7 +768,7 @@ void cmd_watch1 (int on_read, int on_write) { arg = getarg (); if (!arg) - return; + break; if (!strcmp (arg, "print")) br->keep_running = 1; @@ -948,15 +955,15 @@ void cmd_regs (void) void cmd_pc(void) { - char* arg = getarg(); - if (!arg) - { - cmd_regs(); - return; - } + char* arg = getarg(); + if (!arg) + { + cmd_regs(); + return; + } - set_pc(eval_mem(arg, LVALUE)); - cmd_list(); + set_pc(eval_mem(arg, LVALUE)); + cmd_list(); } void cmd_vars (void) @@ -1181,38 +1188,36 @@ command_handler_t command_lookup (const char *cmd) int print_insn_long (absolute_address_t addr) { - char buf[64]; - int i; - int size = dasm(buf, addr); - - const char* name; + char buf[64]; + int i; + int size = dasm(buf, addr); - print_device_name(addr >> 28); - putchar(':'); - printf("0x%04X ", addr & 0xFFFFFF); + const char* name; - for (i = 0; i < size; i++) - printf("%02X", abs_read8(addr + i)); + print_device_name(addr >> 28); + putchar(':'); + printf("0x%04X ", addr & 0xFFFFFF); - for (i = 0; i < 4 - size; i++) - printf(" "); + for (i = 0; i < size; i++) + printf("%02X", abs_read8(addr + i)); - name = sym_lookup(&program_symtab, addr); - if (name) - printf(" %-12.12s", name); - else - printf("%-14.14s", ""); - - printf("%s", buf); + for (i = 0; i < 4 - size; i++) + printf(" "); - putchar ('\n'); + name = sym_lookup(&program_symtab, addr); + if (name) + printf(" %-12.12s", name); + else + printf("%-14.14s", ""); - return size; + printf("%s", buf); + putchar ('\n'); + return size; } void print_current_insn (void) { - print_insn_long(to_absolute(get_pc())); + print_insn_long(to_absolute(get_pc())); } int command_exec (FILE *infile) @@ -1364,37 +1369,37 @@ void command_insn_hook (void) { target_addr_t pc; absolute_address_t abspc; - breakpoint_t *br; + breakpoint_t *br; pc = get_pc (); command_trace_insn (pc); - if (active_break_count == 0) - return; + if (active_break_count == 0) + return; - abspc = to_absolute (pc); - br = brkfind_by_addr (abspc); - if (br && br->enabled && br->on_execute) - { - breakpoint_hit (br); - if (monitor_on == 0) - return; - if (br->temp) - brkfree (br); - else - printf ("Breakpoint %d reached.\n", br->id); - } + abspc = to_absolute (pc); + br = brkfind_by_addr (abspc); + if (br && br->enabled && br->on_execute) + { + breakpoint_hit (br); + if (monitor_on == 0) + return; + if (br->temp) + brkfree (br); + else + printf ("Breakpoint %d reached.\n", br->id); + } } void command_read_hook (absolute_address_t addr) { - breakpoint_t *br; + breakpoint_t *br; if (active_break_count == 0) return; br = brkfind_by_addr (addr); - if (br && br->enabled && br->on_read) + if (br && br->enabled && br->on_read) { printf ("Watchpoint %d triggered. [", br->id); print_addr (addr); @@ -1405,7 +1410,7 @@ void command_read_hook (absolute_address_t addr) void command_write_hook (absolute_address_t addr, U8 val) { - breakpoint_t *br; + breakpoint_t *br; if (active_break_count != 0) { @@ -1416,15 +1421,13 @@ void command_write_hook (absolute_address_t addr, U8 val) { int mask_ok = ((br->last_write & br->write_mask) != (val & br->write_mask)); - br->last_write = val; if (!mask_ok) return; } breakpoint_hit (br); - if (monitor_on == 0) - return; + printf ("Watchpoint %d triggered. [", br->id); print_addr (addr); printf (" = 0x%02X", val); @@ -1455,37 +1458,37 @@ void command_periodic (void) } void pc_virtual (unsigned long *val, int writep) { - writep ? set_pc (*val) : (*val = get_pc ()); + writep ? set_pc (*val) : (*val = get_pc ()); } void x_virtual (unsigned long *val, int writep) { - writep ? set_x (*val) : (*val = get_x ()); + writep ? set_x (*val) : (*val = get_x ()); } void y_virtual (unsigned long *val, int writep) { - writep ? set_y (*val) : (*val = get_y ()); + writep ? set_y (*val) : (*val = get_y ()); } void u_virtual (unsigned long *val, int writep) { - writep ? set_u (*val) : (*val = get_u ()); + writep ? set_u (*val) : (*val = get_u ()); } void s_virtual (unsigned long *val, int writep) { - writep ? set_s (*val) : (*val = get_s ()); + writep ? set_s (*val) : (*val = get_s ()); } void d_virtual (unsigned long *val, int writep) { - writep ? set_d (*val) : (*val = get_d ()); + writep ? set_d (*val) : (*val = get_d ()); } void a_virtual (unsigned long *val, int writep) { - writep ? set_a (*val) : (*val = get_a ()); + writep ? set_a (*val) : (*val = get_a ()); } void b_virtual (unsigned long *val, int writep) { - writep ? set_b (*val) : (*val = get_b ()); + writep ? set_b (*val) : (*val = get_b ()); } void dp_virtual (unsigned long *val, int writep) { - writep ? set_dp (*val) : (*val = get_dp ()); + writep ? set_dp (*val) : (*val = get_dp ()); } void cc_virtual (unsigned long *val, int writep) { - writep ? set_cc (*val) : (*val = get_cc ()); + writep ? set_cc (*val) : (*val = get_cc ()); } void irq_load_virtual (unsigned long *val, int writep) { - if (!writep) + if (!writep) *val = irq_cycles / IRQ_CYCLE_COUNTS; } @@ -1536,10 +1539,10 @@ void command_init (void) sym_add (&auto_symtab, "et", (unsigned long)et_virtual, SYM_AUTO); sym_add (&auto_symtab, "irqload", (unsigned long)irq_load_virtual, SYM_AUTO); - examine_type.format = 'x'; + examine_type.format = 'X'; /* hex with upper-case A-F */ examine_type.size = 1; - print_type.format = 'x'; + print_type.format = 'X'; print_type.size = 1; command_input = stdin; From 1163739c5061dcec2c47ca6bd668f8167dbec611 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 22 Jul 2016 23:26:34 +0100 Subject: [PATCH 36/71] Describe debug commands in more detail. --- README | 160 ++++++++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 141 insertions(+), 19 deletions(-) diff --git a/README b/README index 6f8e4c3..36eee37 100644 --- a/README +++ b/README @@ -84,45 +84,103 @@ The simulator supports interactive debugging similar to that provided by 'gdb'. b - Set a breakpoint at the given address. + Set a breakpoint on EXECUTION at the given address. Eg: + break 0xf003 + - break next time + break 0xf000 ignore 4 + - ignore 4 times then break on 5th time + break 0x1200 if + break 0x1200 if $s==02:0x0043 + - break if the S register has the value shown. + +wa + Set a watchpoint on WRITE to the given address. Eg: + wa 0xf003 + - break and report on each write to this address. + wa 0xf003 print + - on each write to this address report but do not stop + execution. + wa 0xf003 mask 0x10 + - break and report on each write to this address but + only if the write data ANDed with the mask value is + non-zero. + +rwa + Set a watchpoint on READ from the given address. See + examples above for 'wa'. + +awa + Set a watchpoint on ACCESS (read or write) at the given + address. See examples above for 'wa'. bl List all breakpoints/watchpoints. -c - Continue running. - d Delete a breakpoint/watchpoint. -di - Add a display expression. The value of the expression - is display anytime the CPU breaks. +c + Continue execution. -h +di + Add a display expression. The value of the expression + is displayed any time that the CPU breaks. Eg: + di $d $x $y + - print current value of D X and Y registers each time + the CPU breaks. + +dump + Save machine-specific state information to a file, + typically named .dmp. The dump might be + in readable or in binary format. + +dumpi <1 | 0> + Turn instruction dump on or off. With no argument, report + the current instruction dump state (on or off). + With instruction dump off, the 'c', 'n', 's' commands + will report the last instruction that was executed before + control returned to the prompt. With instruction dump on, + those commands report each instruction as it is executed. + Instruction dump is OFF by default. + +h or ? Display help. l - List CPU instructions. + List (disassemble) CPU instructions. Default is to start + at the current value of the PC. me Measure the amount of time that a function named by takes. n - Continue until the next instruction is reached. - If the current instruction is a call, then - the debugger resumes after control returns. + Continue execution until the Next instruction is reached. + If the current instruction is a call, then the debugger + resumes after control returns. p - Print the value of an expression. See "Expressions" below. + Print the value of an expression. See "Expressions" below. + +pc + Set the CPU program counter to and list + (disassemble) CPU instructions at that address. Without + , acts like 'regs'. q Quit the simulator. +regs + Display the current value of the CPU registers. + + re Reset the CPU/machine. +restore + Restore machine state from a 'dump' file. NOT CURRENTLY + IMPLEMENTED. + runfor Continue but break after a certain period of (simulated) time. @@ -141,21 +199,85 @@ so sym Load a symbol table file. Currently, the only format - supported is an aslink map file. + supported is lwlink map file. td - Dump the last 256 instructions that were executed. + Trace Dump. Display the last 256 instructions that were + executed. -wa - Add a watchpoint. The CPU will break when the - memory given by is modified. +vars + Show all program variables. x - Examine target memory at the address given. + Examine target memory at the address given. Eg: + x/nfu addr + - nfu specifies number, format, unit respectively. See + below. + x/nfu + - continue from previous address, in new format. + x addr + - use previous format, continue from previous address. + x + - use previous format, continue from previous address. + + n is the repeat count (default 1). It specifies how much + memory (counting by units u to display. Display is + formated multi-line if necessary. + f is the display format (default x for hex). Options: + x X d u o a s (match printf) and i (instructions). + u is the unit size (default b for byte). Options: + b (byte) w (word: 2 bytes) + + The addr can be specified as an expression. Eg: + x $pc + x $pc+8 + + white-space is not supported in the expression, so + that '$pc +8' is treated in the same way as '$pc'. info Describe machine, devices and address mapping. +----------------------------------------------------------------- +Symbol Tables + +Exec09 maintains variables, in 3 separate symbol tables: + +- The program table. This is loaded automatically at startup or + using the 'sym' command. The contents of this table is + displayed by the 'vars' command. + Entries in the program table are annotated onto 'list', 'step' + 'x' output. + +- The auto table. The variables in this table are pre-defined. + The following variables refer to CPU registers: + pc a y u s d a b dp cc + The following variables refer to simulator state: + cycles - number of cycles since reset. + et - number of cycles elapsed since et was last inspected. + irqload - the average number of cycles spent in IRQ. + + Auto variables can be referenced in expressions using a $ prefix. + +- The internal table. The ... + + + + +----------------------------------------------------------------- +Expressions + +set + does nothing + +set foo + do_set foo +set var + do_set $ + +set var foo + do_set foo (ie, same as 'set foo') + ----------------------------------------------------------------- Original README text from Arto: From 75acf3a142e0fd443cc1596bdec987491e4c61f1 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Thu, 4 Aug 2016 19:20:36 +0100 Subject: [PATCH 37/71] Massive revamp of expression-handler and associated documentation both of which are now in a far more sane state. --- README | 242 ++++++++++++++++--- command.c | 683 +++++++++++++++++++++++++++++++++--------------------- machine.c | 9 + symtab.c | 16 +- 4 files changed, 650 insertions(+), 300 deletions(-) diff --git a/README b/README index 36eee37..2aca635 100644 --- a/README +++ b/README @@ -80,8 +80,8 @@ Faults Debugging -The simulator supports interactive debugging similar to that -provided by 'gdb'. +The simulator supports interactive debugging, similar to that +provided by 'gdb', using the following commands: b Set a breakpoint on EXECUTION at the given address. Eg: @@ -89,7 +89,7 @@ b - break next time break 0xf000 ignore 4 - ignore 4 times then break on 5th time - break 0x1200 if + break 0x1200 if break 0x1200 if $s==02:0x0043 - break if the S register has the value shown. @@ -159,13 +159,23 @@ n If the current instruction is a call, then the debugger resumes after control returns. -p - Print the value of an expression. See "Expressions" below. +p [format] + Print the value of an expression. See 'Expressions' + below. Eg: + p/f + - f specifies format. See below. + p + - use the previous format. + + f is the display format (default x for hex). Options: + x X d u o a s (match printf). + + TODO: the code supports /u (unit) as well, but the b w + options don't make any obvious difference to the output. pc Set the CPU program counter to and list - (disassemble) CPU instructions at that address. Without - , acts like 'regs'. + (disassemble) CPU instructions at that address. q Quit the simulator. @@ -181,15 +191,25 @@ restore Restore machine state from a 'dump' file. NOT CURRENTLY IMPLEMENTED. -runfor - Continue but break after a certain period of (simulated) time. +runfor [units] + Continue but break after a certain period of (simulated) + time. The time can be expressed in ms (default) or s. + The 'runfor' command cannot be nested; issuing a + 'runfor' cancels any 'runfor that is in progress. Eg: + runfor 100 ms + runfor 1 s + runfor 0 -- give 'bad time value' error, but still + cancels a 'runfor' in progress. s - Step for a certain number of CPU instructions (1 by default). + Step for a certain number of CPU instructions (1 by + default). set - Sets the value of an internal variable or target memory. - See "Expressions" below for details on the syntax. +set var + Sets the value of a location in target memory or the + value of an internal variable. + See 'Expressions' below for details on the syntax. so Run a set of debugger commands from another file. @@ -208,8 +228,8 @@ td vars Show all program variables. -x - Examine target memory at the address given. Eg: +x [format] + Examine target memory at the address . Eg: x/nfu addr - nfu specifies number, format, unit respectively. See below. @@ -232,14 +252,14 @@ x x $pc x $pc+8 - white-space is not supported in the expression, so - that '$pc +8' is treated in the same way as '$pc'. + - see 'Expressions' below. info Describe machine, devices and address mapping. ------------------------------------------------------------------ + Symbol Tables +============= Exec09 maintains variables, in 3 separate symbol tables: @@ -247,7 +267,7 @@ Exec09 maintains variables, in 3 separate symbol tables: using the 'sym' command. The contents of this table is displayed by the 'vars' command. Entries in the program table are annotated onto 'list', 'step' - 'x' output. + and 'x' output. - The auto table. The variables in this table are pre-defined. The following variables refer to CPU registers: @@ -257,32 +277,192 @@ Exec09 maintains variables, in 3 separate symbol tables: et - number of cycles elapsed since et was last inspected. irqload - the average number of cycles spent in IRQ. - Auto variables can be referenced in expressions using a $ prefix. +- The internal table. Variables are added to this table + using the 'set var' command. -- The internal table. The ... +The three groups of variables behave in different ways: +Entries in the program table: +- converted to absolute address values when they are loaded. +- cannot be modified. +- new entries cannot be created interactively +- return either an address (their value) or the data at + the addressed location, depending upon the context. +Eg: consider a variable 'start' referring to address 0x200. +The byte at address 0x200 is 0xab. ------------------------------------------------------------------ -Expressions +set start=5 -- changes the byte at address 0x200 + from 0xab to 0x05. +print start -- displays byte from location 0x200 +print &start -- displays 0x200 +break start -- breakpoint at 0x200 +list start -- list at 0x200 +examine start -- read/display memory at 0x200 -set - does nothing +Entries in the auto table: -set foo - do_set foo -set var - do_set $ +- can be modified +- new entries cannot be created interactively +- a print always returns the value +- a set always changes the value (no memory read/write) -set var foo - do_set foo (ie, same as 'set foo') +Entries in the internal table: + +- can be created interactivelt using 'set var' +- can be modified +- are not converted to absolute address values +- return either an address (their value) or the data at + the addressed location, depending upon the context. + +Eg: consider the creation of a variable 'fred' from a +pre-existing program variable 'start': + +set var fred=&start+2 + +'fred' can now be used in exactly the same way as the +examples above showed for 'start'. + + +Expressions +=========== + +Many of the debug commands accept an expression. An expression +is one or more numbers or variables, combined using operators. +Eg: $pc+8 + +Depending on the context, an expression might be an rvalue or +might be of the form lvalue=rvalue. In both cases, no +white-space is allowed: the expression is silently truncated +at the white-space, so that $pc + 8 is treated the same way +as $pc. + +The 'print' command evalutes and displays the value of an +rvalue and simultaneously creates an auto-table entry of the +form $ where increments for each successive command. +Eg: + +$1 = 0x12 +(dbg) print 2 + 4 +$2 = 0x02 +(dbg) print $1 +$3 = 0x12 + +The values of these auto-table entries ($1, $2, $3 etc.) are +static. Eg: + +(dbg) print $pc +$4 = 0xE012 +(dbg) step +02:0x0013 6EB1 JMP [,Y++] +(dbg) print $pc +$5 = 0xE013 +(dbg) print $4 +$6 = 0xE012 + +In this example, the 'print $4' returned the original value +calculated, not the value resulting from the update of pc. + +There are also two short-hand forms for referring to $ +values: + +$ refers to the most recent entry +$$n refers to the value from n entries ago. +$ is equivalent to $$0. + +Eg: + +(dbg) print 5 +$0 = 0x05 +(dbg) print 6 +$1 = 0x06 +(dbg) print 7 +$2 = 0x07 +(dbg) print 8 +$3 = 0x08 +(dbg) print $$2 +$4 = 0x06 +(dbg) print $ +$5 = 0x06 + +The 'print' command also accepts an expression of the form +lvalue=rvalue in which case it performs a memory store (like +'set') but also displays the value written. Eg: + +(dbg) print 0=0xab +$60 = 0x00ab +(dbg) x/4X 0 +01:0x0000 : 0xAB 0xE5 0x1D 0x5A + +The 'set' command can change memory and can create/change +entries in the internal symbol table. Eg: + +(dbg) x/4 0 +01:0x0000 : 0x00 0x00 0x00 0x00 +(dbg) set 0=0x12 +(dbg) set 3=0x1b +(dbg) x 0 +01:0x0000 : 0x12 0x00 0x00 0x1B +(dbg) set var fred=0x10000001 +(dbg) x 0 +01:0x0000 : 0x12 0x00 0x00 0x1B +(dbg) print fred +$0 = 0x00 +(dbg) set fred=0xab +(dbg) x 0 +01:0x0000 : 0x12 0xAB 0x00 0x1B +(dbg) print &fred +$1 = 0x10000001 + +If the lvalue is numeric, it is treated as an address and +the result is a byte write to target memory. If the lvalue +is a variable prefixed with '&' the result is an update to +the variable's value. + +Numbers are implicitly decimal. A leading 0 indicates an +octal number and a leading 0x indicates a hex number. + +The following operators are supported: + +unary +, unary -, +, -, *, / == != & + +Evaluation of expressions follows the usual rule that *, / bind +more tightly than +, - so that '4+3*7' evaluates to the same +result as '3*7+4'. + +The result of ==, != is 1 (true) or 0 (false). + +The '&' is an indirection operator. &4 is the contents of +address 4 in the target machine (however, this is of limited +use because only byte access is supported). + +The following expression errors are detected and reported: + +- bad operator in expression +- bad lvalue +- bad rvalue +- non-existent symbol +- non-existent auto symbol +- bad numeric literal +- unrecognised $symbol in assignment +- missing assignment + +However, the error-checking is not rigorous. In particular: + +- an expression is silently truncated at first white-space +- an unrecognised operator is silently ignored +- set 3+1=9 does a write to location 4, but you cannot use + arithmetic on the LHS with variables. +- an error in an assignment is reported but the assignment + may have happened (Eg, to the wrong location or with the + wrong value). ----------------------------------------------------------------- Original README text from Arto: -simple 6809 simulator under GPL licence +simple 6809 simulator under GPL licencel NOTE! this software is beta stage, and has bugs. To compile it you should have 32-bit ANSI C complier. diff --git a/command.c b/command.c index e1ba931..5241cb8 100644 --- a/command.c +++ b/command.c @@ -1,3 +1,5 @@ +/* -*- c-file-style: "ellemtel" -*- */ + #include "6809.h" #include "monitor.h" #include "machine.h" @@ -76,8 +78,8 @@ unsigned int irq_cycle_tab[IRQ_CYCLE_COUNTS] = { 0, }; unsigned int irq_cycle_entry = 0; unsigned long irq_cycles = 0; -unsigned long eval (char *expr); -unsigned long eval_mem (char *expr, eval_mode_t mode); +unsigned long eval (char *expr, char *eflag); +unsigned long eval_mem (char *expr, eval_mode_t mode, char *eflag); extern int auto_break_insn_count; FILE *command_input; @@ -111,6 +113,18 @@ void syntax_error (const char *string) fprintf (stderr, "error: %s\n", string); } +void report_errors (const char eflag) +{ + if (eflag & 1) fprintf (stderr, "error: bad operator in expression\n"); + if (eflag & 2) fprintf (stderr, "error: bad lvalue in expression\n"); + if (eflag & 4) fprintf (stderr, "error: bad rvalue in expression\n"); + if (eflag & 8) fprintf (stderr, "error: non-existent symbol in expression\n"); + if (eflag & 0x10) fprintf (stderr, "error: non-existent $symbol in expression\n"); + if (eflag & 0x20) fprintf (stderr, "error: bad numeric literal\n"); + if (eflag & 0x40) fprintf (stderr, "error: unrecognised $symbol in assignment\n"); + if (eflag & 0x80) fprintf (stderr, "error: missing assignment\n"); +} + void save_value (unsigned long val) { historytab[history_count++ % MAX_HISTORY] = val; @@ -121,65 +135,65 @@ unsigned long eval_historical (unsigned int id) return historytab[id % MAX_HISTORY]; } -void assign_virtual (const char *name, unsigned long val) +void assign_virtual (const char *name, unsigned long val, char *eflag) { unsigned long v_val; - /* First check for a special variable with this name, and - * invoke its write handler. Otherwise, store to the - * user table. */ if (!sym_find (&auto_symtab, name, &v_val, 0)) { virtual_handler_t virtual = (virtual_handler_t)v_val; - virtual (&val, 1); + virtual (&val, 1); return; } - sym_set (&internal_symtab, name, val, 0); - - if (!strcmp (name, "thread_current")) + else if (!strcmp (name, "thread_current")) { printf ("Thread pointer initialized to "); print_addr (val); putchar ('\n'); thread_current = val; } + else + { + *eflag = *eflag | 0x40; /* not found */ + } } -unsigned long eval_virtual (const char *name) +unsigned long eval_virtual (const char *name, char *eflag) { - unsigned long val; + unsigned long val; - /* The name of the virtual is looked up in the global - * symbol table, which holds the pointer to a - * variable in simulator memory, or to a function - * that can compute the value on-the-fly. */ - if (!sym_find (&auto_symtab, name, &val, 0)) - { - virtual_handler_t virtual = (virtual_handler_t)val; - virtual (&val, 0); - } - else if (!sym_find (&internal_symtab, name, &val, 0)) + /* The name of the virtual is looked up in the auto + * symbol table, which holds a function that can + * compute the value on-the-fly. If not found there + * a value of 0 is returned along with an error flag. + */ + if (!sym_find (&auto_symtab, name, &val, 0)) { + virtual_handler_t virtual = (virtual_handler_t)val; + virtual (&val, 0); } else { - return 0; + *eflag = *eflag | 0x10; + val = 0; } - return val; + return val; } -void eval_assign (char *expr, unsigned long val) +void eval_assign (char *expr, unsigned long val, char *eflag) { - if (*expr == '$') - { - assign_virtual (expr+1, val); - } - else - { - absolute_address_t dst = eval_mem(expr, LVALUE); - abs_write8(dst, (U8) val); - } + if (*expr == '$') + { + assign_virtual (expr+1, val, eflag); + } + else + { + absolute_address_t dst = eval_mem(expr, LVALUE, eflag); + + if (!*eflag) + abs_write8(dst, (U8) val); + } } unsigned long target_read (absolute_address_t addr, unsigned int size) @@ -193,6 +207,10 @@ unsigned long target_read (absolute_address_t addr, unsigned int size) } } +/* Extract any valid format flags - ignore anything else + * allows format and size flags to be mingled but provides no way + * to detect and report unrecognised flags) + */ void parse_format_flag (const char *flags, unsigned char *formatp) { while (*flags) @@ -213,6 +231,10 @@ void parse_format_flag (const char *flags, unsigned char *formatp) } } +/* Extract any valid size flags - ignore anything else + * (allows format and size flags to be mingled but provides no way + * to detect and report unrecognised flags) + */ void parse_size_flag (const char *flags, unsigned int *sizep) { while (*flags) @@ -241,34 +263,36 @@ char* match_binary (char *expr, const char *op, char **secondp) return expr; } -int fold_comparisons (char *expr, unsigned long *value) +int fold_comparisons (char *expr, unsigned long *value, char *eflag) { char *p; if (match_binary (expr, "==", &p)) - *value = (eval (expr) == eval (p)); + *value = (eval (expr, eflag) == eval (p, eflag)); else if (match_binary (expr, "!=", &p)) - *value = (eval (expr) != eval (p)); + *value = (eval (expr, eflag) != eval (p, eflag)); else return 0; + return 1; } -int fold_binary (char *expr, const char op, unsigned long *valp) +int fold_binary (char *expr, const char op, unsigned long *valp, char *eflag) { - char *p; - unsigned long val1, val2; + char *p; + unsigned long val1, val2; - if ((p = strchr (expr, op)) == NULL) - return 0; + if ((p = strchr (expr, op)) == NULL) + return 0; /* If the operator is the first character of the expression, - * then it's really a unary and shouldn't match here. */ + * then it's really a unary and shouldn't match here. + */ if (p == expr) return 0; *p++ = '\0'; - val1 = eval (expr); - val2 = eval (p); + val1 = eval (expr, eflag); + val2 = eval (p, eflag); switch (op) { @@ -280,10 +304,10 @@ int fold_binary (char *expr, const char op, unsigned long *valp) return 1; } -/** +/* * Evaluate a memory expression, as an lvalue or rvalue. */ -unsigned long eval_mem (char *expr, eval_mode_t mode) +unsigned long eval_mem (char *expr, eval_mode_t mode, char *eflag) { char *p; unsigned long val; @@ -292,18 +316,21 @@ unsigned long eval_mem (char *expr, eval_mode_t mode) if ((p = strchr (expr, ':')) != NULL) { *p++ = '\0'; - val = MAKE_ADDR (eval (expr), eval (p)); + val = MAKE_ADDR (eval (expr, eflag), eval (p, eflag)); } - else if (isalpha (*expr)) + else if (isalpha (*expr) || (*expr == '_')) { - if (sym_find (&program_symtab, expr, &val, 0)) + if (!sym_find (&program_symtab, expr, &val, 0)); + else if (!sym_find (&internal_symtab, expr, &val, 0)); + else + { val = 0; + *eflag = *eflag | 8; + } } else { - /* TODO - if expr is already in absolute form, - this explodes ! */ - val = to_absolute (eval (expr)); + val = to_absolute (eval (expr, eflag)); } /* If mode is RVALUE, then dereference it */ @@ -313,7 +340,7 @@ unsigned long eval_mem (char *expr, eval_mode_t mode) return val; } -/** +/* * Evaluate an expression, given as a string. * The return is the value (rvalue) of the expression. * @@ -321,44 +348,58 @@ unsigned long eval_mem (char *expr, eval_mode_t mode) * - Support typecasts ( {TYPE}ADDR ) * */ -unsigned long eval(char *expr) +unsigned long eval(char *expr, char *eflag) { char *p; unsigned long val; - if (fold_comparisons (expr, &val)); + if (fold_comparisons (expr, &val, eflag)); else if ((p = strchr (expr, '=')) != NULL) - { + { + /* Assignment. Change = to 0 to break the string in two. + * Remainder of eval is the LHS, p is the RHS + */ *p++ = '\0'; - val = eval (p); - eval_assign (expr, val); - } - else if (fold_binary (expr, '+', &val)); - else if (fold_binary (expr, '-', &val)); - else if (fold_binary (expr, '*', &val)); - else if (fold_binary (expr, '/', &val)); + val = eval (p, eflag); /* Evaluate RHS */ + eval_assign (expr, val, eflag); /* Evaluate LHS and assign RHS value */ + } + else if (fold_binary (expr, '+', &val, eflag)); + else if (fold_binary (expr, '-', &val, eflag)); + else if (fold_binary (expr, '*', &val, eflag)); + else if (fold_binary (expr, '/', &val, eflag)); else if (*expr == '$') { - if (expr[1] == '$') - val = eval_historical (history_count - strtoul (expr+2, NULL, 10)); - else if (isdigit (expr[1])) + if (expr[1] == '$') /* $$n */ + val = eval_historical (history_count-1 - strtoul (expr+2, NULL, 10)); + else if (isdigit (expr[1])) /* $n */ val = eval_historical (strtoul (expr+1, NULL, 10)); - else if (!expr[1]) - val = eval_historical (0); - else - val = eval_virtual (expr+1); + else if (!expr[1]) /* $ */ + val = eval_historical (history_count-1); + else /* variable from one of the symbol tables */ + val = eval_virtual (expr+1, eflag); } + /* For a symbol 'fred' 'print fred' and 'set fred=4' + * treat fred as an RVALUE so they read and write memory + * at the address associated with the value of fred. + * 'print &fred' and 'set &fred=4' display and change + * the value of the symbol fred. + */ else if (*expr == '&') { - val = eval_mem (expr+1, LVALUE); + val = eval_mem (expr+1, LVALUE, eflag); } - else if (isalpha (*expr)) + else if (isalpha (*expr) || (*expr == '_')) { - val = eval_mem (expr, RVALUE); + val = eval_mem (expr, RVALUE, eflag); } + /* Try to interpet it as a numeric literal */ else { - val = strtoul (expr, NULL, 0); + val = strtoul (expr, &p, 0); + if (expr==p) + { + *eflag = *eflag | 0x20; + } } return val; @@ -366,14 +407,14 @@ unsigned long eval(char *expr) void brk_enable(breakpoint_t *br, int flag) { - if (br->enabled != flag) - { - br->enabled = flag; - if (flag) - active_break_count++; - else - active_break_count--; - } + if (br->enabled != flag) + { + br->enabled = flag; + if (flag) + active_break_count++; + else + active_break_count--; + } } breakpoint_t* brkalloc (void) @@ -394,7 +435,7 @@ breakpoint_t* brkalloc (void) brk_enable (br, 1); return br; } - return NULL; + return NULL; } void brkfree (breakpoint_t *br) @@ -417,14 +458,14 @@ breakpoint_t* brkfind_by_addr (absolute_address_t addr) { unsigned int n; for (n = 0; n < MAX_BREAKS; n++) - if (breaktab[n].addr == addr) - return &breaktab[n]; - return NULL; + if (breaktab[n].addr == addr) + return &breaktab[n]; + return NULL; } breakpoint_t* brkfind_by_id (unsigned int id) { - return &breaktab[id]; + return &breaktab[id]; } void brkprint (breakpoint_t *brkpt) @@ -463,13 +504,13 @@ void brkprint (breakpoint_t *brkpt) display_t* display_alloc (void) { unsigned int n; - for (n = 0; n < MAX_DISPLAYS; n++) + for (n = 0; n < MAX_DISPLAYS; n++) { - display_t *ds = &displaytab[n]; - if (!ds->used) + display_t *ds = &displaytab[n]; + if (!ds->used) { ds->used = 1; - return ds; + return ds; /* TODO bug: missing return otherwise */ } } } @@ -523,6 +564,7 @@ void print_value (unsigned long val, datatype_t *typep) void display_print (void) { + char eflag = 0; unsigned int n; char comma = '\0'; @@ -534,13 +576,15 @@ void display_print (void) char expr[256]; strcpy (expr, ds->expr); printf ("%c %s = ", comma, expr); - print_value (eval (expr), &ds->type); + print_value (eval (expr, &eflag), &ds->type); comma = ','; } } if (comma) putchar ('\n'); + if (eflag) + report_errors(eflag); } int print_insn (absolute_address_t addr) @@ -581,7 +625,7 @@ void do_examine (void) { if ((n % objs_per_line) == 0) { - putchar ('\n'); + if (n > 0) putchar ('\n'); print_addr (examine_addr); printf (": "); } @@ -607,20 +651,31 @@ void do_examine (void) void do_print (char *expr) { - unsigned long val = eval (expr); - printf ("$%d = ", history_count); + char eflag = 0; + unsigned long val = eval (expr, &eflag); parse_format_flag (command_flags, &print_type.format); parse_size_flag (command_flags, &print_type.size); - print_value (val, &print_type); - putchar ('\n'); - save_value (val); + + if (eflag) + report_errors(eflag); + else + { + printf ("$%d = ", history_count); + print_value (val, &print_type); + putchar ('\n'); + save_value (val); + } } void do_set (char *expr) { - printf("In do_set with %s\n",expr); - (void)eval (expr); + char eflag = 0; + + (void)eval (expr, &eflag); + /* too late to prevent an assignment, but at least report problems */ + if (eflag) + report_errors(eflag); } /* TODO - WPC */ @@ -641,11 +696,11 @@ void print_thread_data (absolute_address_t th) pc = (b * 0x4000) + (w - 0x4000); pc = MAKE_ADDR (1, pc); print_addr (pc); - //printf ("{ <%04X,%02X>", w, b); } void command_change_thread (void) { + char eflag = 0; target_addr_t addr = (target_addr_t) target_read(thread_current, thread_id_size); absolute_address_t th = to_absolute (addr); @@ -653,7 +708,10 @@ void command_change_thread (void) return; thread_id = th; - if (machine->dump_thread && eval ("$thread_debug")) + /* TODO thread_debug does not exist by default + so this will return an error.. which we'll ignore. + */ + if (machine->dump_thread && eval ("$thread_debug", &eflag)) { if (addr) { @@ -670,6 +728,7 @@ void command_change_thread (void) } } +/* TODO command_stack and command_stack_* are unused */ void command_stack_push (unsigned int reason) { cmdqueue_t *q = &command_stack[++command_stack_depth]; @@ -696,6 +755,7 @@ char* getarg (void) void cmd_print (void) { char *arg = getarg (); + if (arg) do_print (arg); else @@ -706,86 +766,128 @@ void cmd_set (void) { char *arg = getarg (); - if (!arg) - return; if (!strcmp (arg, "var")) - arg = getarg (); + { + /* this form allows the creation of entries + * in the user symbol table. + */ + char *p; + char eflag = 0; + unsigned long val; - if (arg) - do_set (arg); + arg = getarg (); + if ((p = strchr (arg, '=')) != NULL) + { + *p++ = '\0'; + val = eval (p, &eflag); /* Evaluate RHS */ + if (eflag) + report_errors(eflag); + else + sym_set (&internal_symtab, arg, val, 0); + } + else + { + report_errors(0x80); + } + } else - do_set ("$"); + { + /* this form is a memory write */ + if (arg) + do_set (arg); + } } void cmd_examine (void) { + char eflag = 0; char *arg = getarg (); if (arg) - examine_addr = eval_mem (arg, LVALUE); - do_examine (); + examine_addr = eval_mem (arg, LVALUE, &eflag); + + if (eflag) + report_errors(eflag); + else + do_examine (); } void cmd_break (void) { + char eflag = 0; char *arg = getarg (); + if (!arg) return; - unsigned long val = eval_mem (arg, LVALUE); - breakpoint_t *br = brkalloc (); - br->addr = val; - br->on_execute = 1; - arg = getarg (); - if (!arg); - else if (!strcmp (arg, "if")) + unsigned long val = eval_mem (arg, LVALUE, &eflag); + + if (eflag) + report_errors(eflag); + else { - br->conditional = 1; + breakpoint_t *br = brkalloc (); + br->addr = val; + br->on_execute = 1; + arg = getarg (); - strcpy (br->condition, arg); - } - else if (!strcmp (arg, "ignore")) - { - br->ignore_count = atoi (getarg ()); - } + if (!arg); + else if (!strcmp (arg, "if")) + { + br->conditional = 1; + arg = getarg (); + strcpy (br->condition, arg); + } + else if (!strcmp (arg, "ignore")) + { + br->ignore_count = atoi (getarg ()); + } - brkprint (br); + brkprint (br); + } } void cmd_watch1 (int on_read, int on_write) { - char *arg; + char eflag = 0; + char *arg = getarg (); - arg = getarg (); if (!arg) return; - absolute_address_t addr = eval_mem (arg, LVALUE); - breakpoint_t *br = brkalloc (); - br->addr = addr; - br->on_read = on_read; - br->on_write = on_write; - for (;;) + absolute_address_t addr = eval_mem (arg, LVALUE, &eflag); + + if (eflag) + report_errors(eflag); + else { - arg = getarg (); - if (!arg) - break; + breakpoint_t *br = brkalloc (); + br->addr = addr; + br->on_read = on_read; + br->on_write = on_write; - if (!strcmp (arg, "print")) - br->keep_running = 1; - else if (!strcmp (arg, "mask")) + for (;;) { arg = getarg (); - br->write_mask = strtoul (arg, NULL, 0); - } - else if (!strcmp (arg, "if")) - { - arg = getarg (); - br->conditional = 1; - strcpy (br->condition, arg); + if (!arg) + break; + + if (!strcmp (arg, "print")) + br->keep_running = 1; + else if (!strcmp (arg, "mask")) + { + arg = getarg (); + br->write_mask = strtoul (arg, NULL, 0); + } + else if (!strcmp (arg, "if")) + { + arg = getarg (); + br->conditional = 1; + strcpy (br->condition, arg); + } } - } - brkprint (br); + brkprint (br); + } } void cmd_watch (void) @@ -813,10 +915,9 @@ void cmd_break_list (void) void cmd_step (void) { char *arg = getarg (); - if (arg) - auto_break_insn_count = atoi(arg); + if (arg && (auto_break_insn_count = atoi(arg))); else - auto_break_insn_count = 1; + auto_break_insn_count = 1; exit_command_loop = 0; } @@ -835,7 +936,7 @@ void cmd_next (void) br->temp = 1; /* TODO - for conditional branches, should also set a - temp breakpoint at the branch target */ + temp breakpoint at the branch target */ exit_command_loop = 0; } @@ -878,15 +979,15 @@ void cmd_delete (void) void cmd_list (void) { - char *arg; + char eflag = 0; + char *arg = getarg (); static absolute_address_t lastpc = 0; static absolute_address_t lastaddr = 0; absolute_address_t addr; int n; - arg = getarg (); if (arg) - addr = eval_mem (arg, LVALUE); + addr = eval_mem (arg, LVALUE, &eflag); else { addr = to_absolute (get_pc ()); @@ -896,12 +997,17 @@ void cmd_list (void) lastaddr = lastpc = addr; } - for (n = 0; n < 16; n++) + if (eflag) + report_errors(eflag); + else { - addr += print_insn_long(addr); - } + for (n = 0; n < 16; n++) + { + addr += print_insn_long(addr); + } - lastaddr = addr; + lastaddr = addr; + } } void cmd_symbol_file (void) @@ -913,6 +1019,7 @@ void cmd_symbol_file (void) void cmd_display (void) { + char eflag = 0; char *arg; while ((arg = getarg ()) != NULL) @@ -922,6 +1029,11 @@ void cmd_display (void) ds->type = print_type; parse_format_flag (command_flags, &ds->type.format); parse_size_flag (command_flags, &ds->type.size); + if (eflag) + { + report_errors(eflag); + break; + } } } @@ -955,73 +1067,120 @@ void cmd_regs (void) void cmd_pc(void) { + char eflag = 0; + unsigned long val; char* arg = getarg(); + if (!arg) - { - cmd_regs(); return; - } - set_pc(eval_mem(arg, LVALUE)); - cmd_list(); + val = eval_mem(arg, LVALUE, &eflag); + + if (eflag) + report_errors(eflag); + else + { + set_pc(val); + cmd_list(); + } } void cmd_vars (void) { - for_each_var (NULL); + struct symtab *symtab = &program_symtab; /* default */ + char* arg = getarg(); + if (arg && !strcmp(arg, "auto")) + { + symtab = &auto_symtab; + printf("Print auto\n"); + } + else if (arg && !strcmp(arg, "internal")) + { + symtab = &internal_symtab; + printf("Print internal\n"); + } + symtab_print (symtab); } void cmd_runfor (void) { - char *arg = getarg (); + char eflag = 0; char *units; + char *arg = getarg (); + + if (!arg) + return; + unsigned long val = atoi (arg); + /* do the check here because, even if there is + an error with the new args, we will abandon + any previous runfor that's in progress + */ + if (stop_after_ms != 0) + printf ("Previous 'runfor' abandoned\n"); + units = getarg (); if (!units || !strcmp (units, "ms")) stop_after_ms = val; else if (!strcmp (units, "s")) stop_after_ms = val * 1000; - exit_command_loop = 0; + else + eflag = 1; + + if (eflag) + fprintf (stderr, "error: bad time units\n"); + else if (val == 0) + fprintf (stderr, "error: bad time value\n"); + else + exit_command_loop = 0; } void cmd_measure (void) { + char eflag = 0; absolute_address_t addr; target_addr_t retaddr = get_pc (); breakpoint_t *br; /* Get the address of the function to be measured. */ char *arg = getarg (); + if (!arg) return; - addr = eval_mem (arg, LVALUE); - printf ("Measuring "); - print_addr (addr); - printf (" back to "); - print_addr (to_absolute (retaddr)); - putchar ('\n'); - /* Push the current PC onto the stack for the - duration of the measurement. */ - set_s (get_s () - 2); - write16 (get_s (), retaddr); + addr = eval_mem (arg, LVALUE, &eflag); + if (eflag) + report_errors(eflag); + else + { + printf ("Measuring "); + print_addr (addr); + printf (" back to "); + print_addr (to_absolute (retaddr)); + putchar ('\n'); + + /* Push the current PC onto the stack for the + duration of the measurement. */ + set_s (get_s () - 2); + write16 (get_s (), retaddr); - /* Set a temp breakpoint at the current PC, so that - the measurement will halt. */ - br = brkalloc (); - br->addr = to_absolute (retaddr); - br->on_execute = 1; - br->temp = 1; + /* Set a temp breakpoint at the current PC, so that + the measurement will halt. */ + br = brkalloc (); + br->addr = to_absolute (retaddr); + br->on_execute = 1; + br->temp = 1; - /* Interrupts must be disabled for this to work ! */ - set_cc (get_cc () | 0x50); + /* Interrupts must be disabled for this to work ! */ + set_cc (get_cc () | 0x50); - /* Change the PC to the function-under-test. */ - set_pc (addr); + /* Change the PC to the function-under-test. */ + set_pc (addr); - /* Go! */ - exit_command_loop = 0; + /* Go! */ + exit_command_loop = 0; + } } void cmd_dump_insns (void) @@ -1032,7 +1191,7 @@ void cmd_dump_insns (void) if (arg) dump_every_insn = strtoul (arg, NULL, 0); printf ("Instruction dump is %s\n", - dump_every_insn ? "on" : "off"); + dump_every_insn ? "on" : "off"); } void cmd_trace_dump (void) @@ -1049,17 +1208,17 @@ void cmd_trace_dump (void) void cmd_dump (void) { - dump_machine(); + dump_machine(); } void cmd_restore (void) { - printf("not implemented\n"); + printf("not implemented\n"); } void cmd_info (void) { - describe_machine(); + describe_machine(); } /****************** Parser ************************/ @@ -1068,70 +1227,70 @@ void cmd_help (void); struct command_name { - const char *prefix; - const char *name; - command_handler_t handler; - const char *help; + const char *prefix; + const char *name; + command_handler_t handler; + const char *help; } cmdtab[] = { { "p", "print", cmd_print, - "Print the value of an expression" }, + "Print the value of an expression" }, { "set", "set", cmd_set, - "Set an internal variable/target memory" }, + "Set an internal variable/target memory" }, { "x", "examine", cmd_examine, - "Examine raw memory" }, + "Examine raw memory" }, { "b", "break", cmd_break, - "Set a breakpoint" }, + "Set a breakpoint" }, { "bl", "blist", cmd_break_list, - "List all breakpoints/watchpoints" }, + "List all breakpoints/watchpoints" }, { "d", "delete", cmd_delete, - "Delete a breakpoint/watchpoint" }, + "Delete a breakpoint/watchpoint" }, { "s", "step", cmd_step, - "Step one (or more) instructions" }, + "Step one (or more) instructions" }, { "n", "next", cmd_next, - "Break at the next instruction" }, + "Break at the next instruction" }, { "c", "continue", cmd_continue, - "Continue the program" }, + "Continue the program" }, { "fg", "foreground", cmd_continue, NULL }, { "q", "quit", cmd_quit, - "Quit the simulator" }, + "Quit the simulator" }, { "re", "reset", cpu_reset, - "Reset the CPU" }, + "Reset the CPU" }, { "h", "help", cmd_help, - "Display this help" }, + "Display this help" }, { "wa", "watch", cmd_watch, - "Add a watchpoint on write" }, + "Add a watchpoint on write" }, { "rwa", "rwatch", cmd_rwatch, - "Add a watchpoint on read" }, + "Add a watchpoint on read" }, { "awa", "awatch", cmd_awatch, - "Add a watchpoint on read/write" }, + "Add a watchpoint on read/write" }, { "?", "?", cmd_help }, { "l", "list", cmd_list }, { "sym", "symbol-file", cmd_symbol_file, - "Open a symbol table file" }, + "Open a symbol table file" }, { "di", "display", cmd_display, - "Add a display expression" }, + "Add a display expression" }, { "so", "source", cmd_source, - "Run a command script" }, + "Run a command script" }, { "regs", "regs", cmd_regs, - "Show all CPU registers" }, + "Show all CPU registers" }, { "vars", "vars", cmd_vars, - "Show all program variables" }, + "Show all program variables" }, { "runfor", "runfor", cmd_runfor, - "Run for a certain amount of time" }, + "Run for a certain amount of time" }, { "me", "measure", cmd_measure, - "Measure time that a function takes" }, + "Measure time that a function takes" }, { "dumpi", "dumpi", cmd_dump_insns, - "Set dump-instruction flag" }, + "Set dump-instruction flag" }, { "td", "tracedump", cmd_trace_dump, - "Dump the trace buffer" }, + "Dump the trace buffer" }, { "dump", "du", cmd_dump, - "Dump contents of memory to a file" }, + "Dump contents of memory to a file" }, { "restore", "res", cmd_restore, - "Restore contents of memory from a file" }, + "Restore contents of memory from a file" }, { "i", "info", cmd_info, - "Describe machine, devices and address mapping" }, + "Describe machine, devices and address mapping" }, { "pc", "pc", cmd_pc, - "Set program counter" }, + "Set program counter" }, #if 0 { "cl", "clear", cmd_clear }, { "co", "condition", cmd_condition }, @@ -1139,9 +1298,9 @@ struct command_name { "di", "disable", cmd_disable }, { "en", "enable", cmd_enable }, { "f", "file", cmd_file, - "Choose the program to be debugged" }, + "Choose the program to be debugged" }, { "exe", "exec-file", cmd_exec_file, - "Open an executable" }, + "Open an executable" }, #endif { NULL, NULL }, }; @@ -1153,7 +1312,7 @@ void cmd_help (void) { if (cn->help) printf ("%s (%s) - %s\n", - cn->name, cn->prefix, cn->help); + cn->name, cn->prefix, cn->help); cn++; } } @@ -1243,16 +1402,16 @@ int command_exec (FILE *infile) else #endif { - if (infile == stdin) - printf ("(dbg) "); - fgets (buffer, 255, infile); - if (feof (infile)) - return -1; + if (infile == stdin) + printf ("(dbg) "); + fgets (buffer, 255, infile); + if (feof (infile)) + return -1; } } while (errno != 0); /* In terminal mode, a blank line means to execute - the previous command. */ + the previous command. */ if (buffer[0] == '\n') strcpy (buffer, prev_buffer); @@ -1280,30 +1439,30 @@ int command_exec (FILE *infile) void keybuffering_defaults (void) { #ifndef _MSC_VER - /* Extract and save defaults associated with buffered io, create - settings associated with unbuffered io - */ + /* Extract and save defaults associated with buffered io, create + settings associated with unbuffered io + */ - /* get the terminal settings for stdin */ - tcgetattr(STDIN_FILENO,&old_tio); + /* get the terminal settings for stdin */ + tcgetattr(STDIN_FILENO,&old_tio); - /* start with the current settings */ - new_tio=old_tio; + /* start with the current settings */ + new_tio=old_tio; - /* disable canonical mode (buffered i/o) and local echo */ - new_tio.c_lflag &=(~ICANON & ~ECHO); + /* disable canonical mode (buffered i/o) and local echo */ + new_tio.c_lflag &=(~ICANON & ~ECHO); #endif } void keybuffering (int flag) { #ifndef _MSC_VER - if (flag) { - tcsetattr(STDIN_FILENO,TCSANOW,&old_tio); - } - else { - tcsetattr(STDIN_FILENO,TCSANOW,&new_tio); - } + if (flag) { + tcsetattr(STDIN_FILENO,TCSANOW,&old_tio); + } + else { + tcsetattr(STDIN_FILENO,TCSANOW,&new_tio); + } #endif } @@ -1312,7 +1471,7 @@ int command_loop (void) keybuffering (1); brkfree_temps (); -restart: + restart: if (command_input == stdin) { display_print (); @@ -1341,12 +1500,14 @@ int command_loop (void) void breakpoint_hit (breakpoint_t *br) { + /* TODO don't know how best to handle errors here. */ + char eflag = 0; /* unused */ if (br->threaded && (thread_id != br->tid)) return; if (br->conditional) { - if (eval (br->condition) == 0) + if (eval (br->condition, &eflag) == 0) return; } @@ -1375,19 +1536,19 @@ void command_insn_hook (void) command_trace_insn (pc); if (active_break_count == 0) - return; + return; abspc = to_absolute (pc); br = brkfind_by_addr (abspc); if (br && br->enabled && br->on_execute) { - breakpoint_hit (br); - if (monitor_on == 0) - return; - if (br->temp) - brkfree (br); - else - printf ("Breakpoint %d reached.\n", br->id); + breakpoint_hit (br); + if (monitor_on == 0) + return; + if (br->temp) + brkfree (br); + else + printf ("Breakpoint %d reached.\n", br->id); } } @@ -1420,7 +1581,7 @@ void command_write_hook (absolute_address_t addr, U8 val) if (br->write_mask) { int mask_ok = ((br->last_write & br->write_mask) != - (val & br->write_mask)); + (val & br->write_mask)); br->last_write = val; if (!mask_ok) return; diff --git a/machine.c b/machine.c index 2c7a9fa..0110886 100644 --- a/machine.c +++ b/machine.c @@ -29,6 +29,7 @@ #define MISSING 0xff #define mmu_device (device_table[0]) +extern FILE *log_file; struct machine *machine; unsigned int device_count = 0; @@ -281,6 +282,7 @@ U16 cpu_read16 (unsigned int addr) void cpu_write8 (unsigned int addr, U8 val) { //printf("write 0x%04x<-0x%02x\n", addr, val); + //fprintf(log_file,"wr 0x%04x<-0x%02x\n", addr, val); struct bus_map *map = find_map (addr); struct hw_device *dev = find_device (addr, map->devid); struct hw_class *class_ptr = dev->class_ptr; @@ -319,6 +321,13 @@ void abs_write8 (absolute_address_t addr, U8 val) absolute_address_t to_absolute (unsigned long cpuaddr) { + /* if it's greater than 0xffff, it's already absolute + and we cannot convert it again. If it's less than + 0x10000 it might already be absolute but it's safe + to convert it a second time. + */ + if (cpuaddr > 0xffff) return (absolute_address_t)cpuaddr; + struct bus_map *map = find_map (cpuaddr); struct hw_device *dev = find_device (cpuaddr, map->devid); unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE; diff --git a/symtab.c b/symtab.c index 0951329..edc4ee1 100644 --- a/symtab.c +++ b/symtab.c @@ -152,7 +152,7 @@ const char *sym_lookup (struct symtab *symtab, unsigned long value) return chain->name; chain = chain->value_chain; } - symtab = symtab->parent; + symtab = symtab->parent; /* [NAC HACK 26Jul2016] ->parent never used. Remove*/ } return NULL; } @@ -163,20 +163,20 @@ struct symbol *sym_add (struct symtab *symtab, { unsigned int hash; struct symbol *s, *chain; - - s = malloc (sizeof (struct symbol)); + + s = malloc (sizeof (struct symbol)); s->name = stringspace_copy (name); s->value = value; s->type = type; s->ty.format = 0; s->ty.size = 0; - - hash = sym_hash_name (name); + + hash = sym_hash_name (name); chain = symtab->syms_by_name[hash]; s->name_chain = chain; symtab->syms_by_name[hash] = s; - hash = sym_hash_value (value); + hash = sym_hash_value (value); chain = symtab->syms_by_value[hash]; s->value_chain = chain; symtab->syms_by_value[hash] = s; @@ -196,9 +196,9 @@ void sym_set (struct symtab *symtab, } -void for_each_var (void (*cb) (struct symbol *, unsigned int size)) +void symtab_print (struct symtab *symtab) { - struct symtab *symtab = &program_symtab; + // struct symtab *symtab = &program_symtab; absolute_address_t addr; const char *id; struct symbol *sym; From 42ebde73bff3722c63b09c159febd5ff956e9542 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 5 Aug 2016 21:24:16 +0100 Subject: [PATCH 38/71] Clarify command-line help: maxcycles can be turned off by setting it to 0. --- main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.c b/main.c index 1efe4ac..3785d69 100644 --- a/main.c +++ b/main.c @@ -190,7 +190,7 @@ struct option { 't', "loadmap", "" }, { 'T', "trace", "", NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL }, - { 'm', "maxcycles", "Sets maximum number of cycles to run", + { 'm', "maxcycles", "Set maximum number of cycles to run (0 to disable)", NO_NEG, HAS_ARG, &max_cycles, 0, NULL, NULL }, { 's', "machine", "Specify the machine (exact hardware) to emulate", NO_NEG, HAS_ARG, NULL, 0, &machine_name, NULL }, From 204c78ed1d98bb280ac6c695c9ddf3788605541f Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 5 Aug 2016 21:28:18 +0100 Subject: [PATCH 39/71] Finally fixed the input code so that it can run non-blocking. Hoorah. Tidied up the multicomp UART emulation to be more consistent and to give better reporting. --- command.c | 34 +++++++-- miscsbc.c | 212 +++++++++++++++++++++++++++++++++++++++++------------- 2 files changed, 190 insertions(+), 56 deletions(-) diff --git a/command.c b/command.c index 5241cb8..fa2da11 100644 --- a/command.c +++ b/command.c @@ -1439,18 +1439,14 @@ int command_exec (FILE *infile) void keybuffering_defaults (void) { #ifndef _MSC_VER - /* Extract and save defaults associated with buffered io, create - settings associated with unbuffered io - */ - /* get the terminal settings for stdin */ + /* get two copies of the terminal settings for stdin */ tcgetattr(STDIN_FILENO,&old_tio); - - /* start with the current settings */ - new_tio=old_tio; + tcgetattr(STDIN_FILENO,&new_tio); /* disable canonical mode (buffered i/o) and local echo */ new_tio.c_lflag &=(~ICANON & ~ECHO); + #endif } @@ -1466,6 +1462,30 @@ void keybuffering (int flag) #endif } + +/* Non-blocking check for input character. If + * true, retreive character using kbchar() + */ +int kbhit() +{ + struct timeval tv = { 0L, 0L }; + fd_set fds; + FD_ZERO(&fds); + FD_SET(0, &fds); + return select(1, &fds, NULL, NULL, &tv); +} + +int kbchar() +{ + int r; + unsigned char c; + if ((r = read(0, &c, sizeof(c))) < 0) { + return r; + } else { + return c; + } +} + int command_loop (void) { keybuffering (1); diff --git a/miscsbc.c b/miscsbc.c index dd4c9c8..6433f32 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -9,7 +9,7 @@ int smii_i_avail = 1; int smii_o_busy = 0; // for multicomp09 sdmapper: values most-recently written to these registers -#define MULTICOMP09_RAMMAX (0x20000) +#define MULTICOMP09_RAMMAX (0x80000) unsigned char mc_mmuadr = 0x00; unsigned char mc_mmudat = 0x00; unsigned char mc_timer = 0x00; @@ -207,28 +207,53 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) //printf("In console_read with addr=0x%08x pc=0x%04x\n", (unsigned int)addr, get_pc()); unsigned char ch; switch (addr) { - case 0: - case 2: - case 4: - // status bit - // hardware supports bits [7], [1], [0] - return 0x03; - case 1: + /* UART0 -----------------------------*/ + case 0: /* status */ + // b7: interrupt + // b1: can accept TX char + // b0: RX char available + return (batch_file || kbhit()) ? 3 : 2; + + case 1: /* data */ if (batch_file && fread( &ch, 1, 1, batch_file)) { } else { - ch = getchar(); + ch = kbchar(); } // key conversions to make keyboard look DOS-like if (ch == 127) return 8; // rubout->backspace if (ch == 10) return 13; // LF->CR return ch; + + /* UART1 -----------------------------*/ + case 2: /* status */ + // hardware supports bits [7], [1], [0] + printf("[uart1 stat rd addr=0x%08x\n", (unsigned int)addr); + return 0x03; + + case 3: /* data */ + printf("[uart1 data rd addr=0x%08x\n", (unsigned int)addr); + return 0x42; + + /* UART2 -----------------------------*/ + case 4: /* status */ + // hardware supports bits [7], [1], [0] + printf("[uart2 stat rd addr=0x%08x\n", (unsigned int)addr); + return 0x03; + + case 5: /* data */ + printf("[uart2 data rd addr=0x%08x\n", (unsigned int)addr); + return 0x42; + + /* GPIO (not modelled) ---------------*/ case 6: case 7: printf("[gpio rd addr=0x%08x]\n", (unsigned int)addr); return 0x42; + + /* Other (should be unreachable) -----*/ default: - printf("In console_read with addr=0x%08x\n", (unsigned int)addr); + printf("ERROR in console_read with addr=0x%08x\n", (unsigned int)addr); return 0x42; } } @@ -236,30 +261,60 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 val) { //printf("In console_write with addr=0x%08x val=0x%02x pc=0x%04x\n", (unsigned int)addr, val, get_pc()); - fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); + //fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { - case 0: - case 2: - case 4: + /* UART0 -----------------------------*/ + case 0: /* status */ if (val==3) { - printf("[uart%1d reset]", (unsigned int)(1 + addr>>1)); + printf("[uart0 reset]"); } else { - printf("[uart%1d status write of 0x%02x\n", (unsigned int)(1 + addr>>1), val); + printf("[uart0 stat wr of 0x%02x\n", val); } break; - case 1: + case 1: /* data */ putchar(val); /* UART 1*/ + fflush(stdout); + break; + + /* UART1 -----------------------------*/ + case 2: /* status */ + if (val==3) { + printf("[uart0 reset]"); + } + else { + printf("[uart0 stat wr of 0x%02x\n", val); + } + break; + + case 3: /* data */ + printf("[uart1 data wr of 0x%02x\n", val); + break; + + /* UART2 -----------------------------*/ + case 4: /* status */ + if (val==3) { + printf("[uart0 reset]"); + } + else { + printf("[uart0 stat wr of 0x%02x\n", val); + } + break; + + case 5: /* data */ + printf("[uart1 data wr of 0x%02x\n", val); break; + /* GPIO (not modelled) ---------------*/ case 6: case 7: printf("[gpio wr addr=0x%08x val=0x%02x]\n", (unsigned int)addr, val); break; + /* Other (should be unreachable) -----*/ default: - printf("In console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); + printf("ERROR in console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); } } @@ -338,15 +393,62 @@ int mmu_flags(int blk) { error if too much data written or read or if command while not idle. */ -void sdmapper_remap(int update_table) + + +/* + op values are: + 0 remap memory using existing register values + 1 load new dat value then remap memory using existing register values + 2 load new adr value then remap memory using new values +*/ +// mc_mmuadr bits: +// 7 ROMDIS +// 6 TR +// 5 MMUEN +// 4 NMI +// 3:0 MAPSEL +// +void sdmapper_remap(int op, int val) { int i; - if (update_table) { - // MMUDAT write, so update appropriate mapping register - mc_pblk[mc_mmuadr & 0xf] = mc_mmudat; + // Update appropriate mapping register if dat written + if (op == 1) { + mc_pblk[mc_mmuadr & 0xf] = val; + if (val > 0x3f) { + printf("Bad: write to mmu map register 0x%01x with data 0x%02x at pc=0x%04x\n",0xf & mc_mmuadr, val, get_pc()); + } + + // If the MMU is enabled and the data register that changed is part of the active mapping, report the mapping + if ( ((mc_mmuadr & 0x68) == 0x68) || ((mc_mmuadr & 0x68) == 0x20) ) { + fprintf(log_file,"INFO mmudat change on active mapping set: mmudat 0x%02x->0x%02x\n",mc_mmudat, val); + fprintf(log_file,"INFO mmuadr 0x%02x pc=0x%04x", mc_mmuadr, get_pc()); + for (i=0;i<16;i++) { + fprintf(log_file," %02d:0x%02x",i,mc_pblk[i]); + } + fprintf(log_file,"\n"); + fflush(NULL); + } + + mc_mmudat = val; } + + if (op == 2) { + // If ROMDIS, TR or MMUEN have changed, report the mapping + if ((mc_mmuadr & 0x70) != (val & 0x70)) { + fprintf(log_file,"INFO mmuadr 0x%02x->0x%02x pc=0x%04x", mc_mmuadr, val, get_pc()); + for (i=0;i<16;i++) { + fprintf(log_file," %02d:0x%02x",i,mc_pblk[i]); + } + fprintf(log_file,"\n"); + fflush(NULL); + } + + mc_mmuadr = val; + } + + // now update mapping based on mc_mmuadr, mc_pblk[] //[NAC HACK 2015May06] Yeuch. Horrible how I have had to hardwire the device numbers. @@ -411,7 +513,7 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) case 0: // SDDATA switch (mc_state) { case 0: case 1: case 2: - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; case 3: // in read if (mc_poll == 3) { @@ -420,23 +522,23 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) mc_state = 2; // final read then back to idle } if (mc_dindex < 512) { - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_data[mc_dindex]); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_data[mc_dindex]); return mc_data[mc_dindex++]; } else { printf("ERROR attempt to read too much data from sd block\n"); - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; } } else { printf("ERROR attempt to read sd block when data not yet available\n"); - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; } case 4: // in write printf("ERROR attempt to read sd data during write command\n"); - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xff); return 0xff; } break; // unreachable @@ -444,47 +546,47 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) switch (mc_state) { case 0: // busy and always will remain so - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x90); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x90); return 0x90; case 1: // count polls and initialise mc_poll++; if (mc_poll == 16) mc_state = 2; - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x90); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x90); return 0x90; case 2: // idle. - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x80); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x80); return 0x80; case 3: // in read if (mc_poll < 3) mc_poll++; if (mc_poll == 3) { - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xe0); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xe0); return 0xe0; // data available } else { - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xa0); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xa0); return 0xa0; // still waiting TODO maybe 20 } case 4: // in write if (mc_poll < 3) mc_poll++; if (mc_poll == 3) { - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xa0); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0xa0); return 0xa0; // space available } else { - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x20); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x20); return 0x20; // still waiting } } break; // unreachable case 5: // TIMER - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_timer); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_timer); return mc_timer; default: printf("INFO In sdmapper_read with addr=0x%08x\n", (unsigned char)addr); - fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x42); + //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x42); return 0x42; } } @@ -494,7 +596,7 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) { int retvar; //printf("INFO In sdmapper_write with addr=0x%08x, mc_state=%d mc_poll=%d mc_dindex=%d\n", addr, mc_state, mc_poll, mc_dindex); - fprintf(log_file,"%02x>%02x\n",(unsigned char)(addr&0xff),val); + //fprintf(log_file,"%02x>%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { case 0: // SDDATA switch (mc_state) { @@ -582,19 +684,31 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) mc_sdlba2 = val; break; case 5: // TIMER - mc_timer = val; + // bit [1] is read/write, timer enable + // bit [7] is read, write-1-to-clear + // Set this up so that it *always* signals an interrupt + // when enabled; when used with the "-I" command-line timer + // interrupt feature, this will make it seem as though this + // timer is the source of all interrupts. + if (val & 2) { + // enabled and signalling interrupt + mc_timer = 0x82; + } + else { + // disabled. Pending interrupt remains or is cleared + // depending upon bit[7] + mc_timer = (val & 0x80) ^ 0x80; + } break; case 6: // MMUADR // ignore writes where bit(4) is set; this is the single-step/nmi control // and it forces the other write data to be ignored if ((val & 0x10) == 0) { - mc_mmuadr = val; - sdmapper_remap(0); // 0=> remap memory based on mc_mmuadr + sdmapper_remap(2, val); } break; case 7: // MMUDAT - mc_mmudat = val; - sdmapper_remap(1); // 1=> update mc_pblk[] then remap memory based on mc_mmuadr + sdmapper_remap(1, val); break; } } @@ -630,7 +744,12 @@ void multicomp09_init (const char *boot_rom_file) struct hw_device* romdev; int i; - /* RAM is 128Kbytes. With MMU disabled low 64K is mapped linearly + /* Log file + */ + log_file = file_open(NULL, "multicomp09.log", "w+b"); + fprintf(log_file, "===Log file\n"); + + /* RAM is 512Kbytes. With MMU disabled low 64K is mapped linearly otherwise, it is mapped in 8K chunks. Each chunk has a separate write protect. */ @@ -689,7 +808,7 @@ void multicomp09_init (const char *boot_rom_file) /* Now map all the devices into the address space, in accordance with the settings of the memory mapper. */ - sdmapper_remap(0); + sdmapper_remap(0, 0); /* If a file multicomp09.bat exists, supply input from it until @@ -706,11 +825,6 @@ void multicomp09_init (const char *boot_rom_file) mc_state = 1; else mc_state = 0; - /* - log file - */ - log_file = file_open(NULL, "multicomp09.log", "w+b"); - fprintf(log_file, "===Log file\n"); } From 5694aef171ae96647a7ed735f955b284e795cf8e Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 6 Sep 2016 13:34:44 +0100 Subject: [PATCH 40/71] Clarify operation of sym command - file has implicit .map extension. --- README | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README b/README index 2aca635..2d27bcc 100644 --- a/README +++ b/README @@ -218,8 +218,8 @@ so source (the file that called it, or the keyboard.) sym - Load a symbol table file. Currently, the only format - supported is lwlink map file. + Load a symbol table file named file.map -- Currently, + the only format supported is an lwlink map file. td Trace Dump. Display the last 256 instructions that were From d981dd6b3d47cc64856f31b388c9a2bbb9c63247 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 6 Sep 2016 14:17:23 +0100 Subject: [PATCH 41/71] reformat to remove open curly on its own line. --- main.c | 97 ++++++++++++++++++++-------------------------------------- 1 file changed, 33 insertions(+), 64 deletions(-) diff --git a/main.c b/main.c index 3785d69..61d655d 100644 --- a/main.c +++ b/main.c @@ -8,12 +8,12 @@ * 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. - * + * * GCC6809 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 GCC6809; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -129,8 +129,7 @@ idle_loop (void) last_cycles = cycles; total_ms_elapsed += sim_ms; - if (total_ms_elapsed > 100) - { + if (total_ms_elapsed > 100) { total_ms_elapsed -= 100; if (machine->periodic) machine->periodic (); @@ -139,8 +138,7 @@ idle_loop (void) delay = sim_ms - real_ms; cumulative_delay += delay; - if (cumulative_delay > 0) - { + if (cumulative_delay > 0) { usleep (50 * 1000UL); cumulative_delay -= 50; } @@ -208,10 +206,8 @@ do_help (const char *arg __attribute__((unused))) printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION); printf ("m6809-run [options] [program]\n\n"); printf ("Options:\n"); - while (opt->o_long != NULL) - { - if (opt->help) - { + while (opt->o_long != NULL) { + if (opt->help) { if (opt->o_short == '-') printf (" --%-16.16s %s\n", opt->o_long, opt->help); else @@ -239,45 +235,36 @@ process_option (struct option *opt, const char *arg) { int rc; //printf ("Processing option '%s'\n", opt->o_long); - if (opt->takes_arg) - { - if (!arg) - { + if (opt->takes_arg) { + if (!arg) { //printf (" Takes argument but none given.\n"); rc = 0; } - else - { - if (opt->int_value) - { + else { + if (opt->int_value) { *(opt->int_value) = strtoul (arg, NULL, 0); //printf (" Integer argument '%d' taken.\n", *(opt->int_value)); } - else if (opt->string_value) - { + else if (opt->string_value) { *(opt->string_value) = arg; //printf (" String argument '%s' taken.\n", *(opt->string_value)); } rc = 1; } } - else - { - if (arg) - { + else { + if (arg) { //printf (" Takes no argument but one given, ignored.\n"); } - if (opt->int_value) - { + if (opt->int_value) { *(opt->int_value) = opt->default_value; //printf (" Integer argument 1 implied.\n"); } rc = 0; } - if (opt->handler) - { + if (opt->handler) { rc = opt->handler (arg); //printf (" Handler called, rc=%d\n", rc); } @@ -304,22 +291,17 @@ parse_args (int argc, char *argv[]) struct option *opt; next_arg: - while (argn < argc) - { + while (argn < argc) { char *arg = argv[argn]; - if (arg[0] == '-') - { - if (arg[1] == '-') - { + if (arg[0] == '-') { + if (arg[1] == '-') { char *rest = strchr (arg+2, '='); if (rest) *rest++ = '\0'; opt = option_table; - while (opt->o_long != NULL) - { - if (!strcmp (opt->o_long, arg+2)) - { + while (opt->o_long != NULL) { + if (!strcmp (opt->o_long, arg+2)) { argn++; (void)process_option (opt, rest); goto next_arg; @@ -328,13 +310,10 @@ parse_args (int argc, char *argv[]) } printf ("long option '%s' not recognized.\n", arg+2); } - else - { + else { opt = option_table; - while (opt->o_long != NULL) - { - if (opt->o_short == arg[1]) - { + while (opt->o_long != NULL) { + if (opt->o_short == arg[1]) { argn++; if (process_option (opt, argv[argn])) argn++; @@ -346,8 +325,7 @@ parse_args (int argc, char *argv[]) } argn++; } - else - { + else { process_plain_argument (argv[argn++]); } } @@ -373,12 +351,10 @@ main (int argc, char *argv[]) sym_init (); - if (binary) - { + if (binary) { machine_init (machine_name, prog_name); } - else - { + else { /* The machine loader cannot deal with image files, so initialize the machine first, passing it a NULL filename, then load the image file afterwards. */ @@ -392,12 +368,10 @@ main (int argc, char *argv[]) load_map_file (prog_name); /* Enable debugging if no executable given yet. */ - if (!prog_name) - { + if (!prog_name) { debug_enabled = 1; } - else - { + else { /* OK, ready to run. Reset the CPU first. */ cpu_reset (); } @@ -411,10 +385,8 @@ main (int argc, char *argv[]) * If no IRQs or FIRQs are enabled, we can just call cpu_execute() * and let it run for a long time; otherwise, we need to come back * here periodically and do the interrupt handling. */ - for (cpu_quit = 1; cpu_quit != 0;) - { - if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) - { + for (cpu_quit = 1; cpu_quit != 0;) { + if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) { /* Simulate some CPU time, either 1ms worth or up to the next possible IRQ */ total += cpu_execute (mhz * 1024); @@ -422,16 +394,14 @@ main (int argc, char *argv[]) /* Call each device that needs periodic processing. */ machine_update (); } - else - { + else { total += cpu_execute (cycles_per_irq); /* TODO - this assumes periodic interrupts (WPC) */ request_irq (0); { /* TODO - FIRQ frequency not handled yet */ static int firq_freq = 0; - if (++firq_freq == 8) - { + if (++firq_freq == 8) { request_firq (0); firq_freq = 0; } @@ -441,8 +411,7 @@ main (int argc, char *argv[]) idle_loop (); /* Check for a rogue program that won't end */ - if ((max_cycles > 0) && (total > max_cycles)) - { + if ((max_cycles > 0) && (total > max_cycles)) { sim_error ("maximum cycle count exceeded at %s\n", monitor_addr_name (get_pc ())); } From ddb6504cddb859abdf1fae9faaca96b1fbcc4b1c Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 6 Sep 2016 16:14:35 +0100 Subject: [PATCH 42/71] Initialise call stack from PC value rather than assuming that the program will start at the reset vector entry point - will give better behaviour once we can load and start programs directly in RAM (tho the call stack stuff is never used for anything at the moment..) --- monitor.c | 158 ++++++++++++++++++++++-------------------------------- 1 file changed, 63 insertions(+), 95 deletions(-) diff --git a/monitor.c b/monitor.c index 1d94ef3..b670027 100644 --- a/monitor.c +++ b/monitor.c @@ -897,29 +897,25 @@ int dasm (char *buf, absolute_address_t opc) op = fetch8(); - if (op == 0x10) - { + if (op == 0x10) { op = fetch8(); am = codes10[op].mode; op = codes10[op].code; - } - else if (op == 0x11) - { + } + else if (op == 0x11) { op = fetch8(); am = codes11[op].mode; op = codes11[op].code; - } - else - { + } + else { am = codes[op].mode; op = codes[op].code; - } + } op_str = (char *) mne[op]; buf += sprintf (buf, "%-6.6s", op_str); - switch (am) - { + switch (am) { case _illegal: sprintf (buf, "???"); break; @@ -942,14 +938,12 @@ int dasm (char *buf, absolute_address_t opc) op = fetch8 (); R = index_reg[(op >> 5) & 0x3]; - if ((op & 0x80) == 0) - { + if ((op & 0x80) == 0) { sprintf (buf, "%s,%c", off4[op & 0x1f], R); break; - } + } - switch (op & 0x1f) - { + switch (op & 0x1f) { case 0x00: sprintf (buf, ",%c+", R); break; @@ -1022,7 +1016,7 @@ int dasm (char *buf, absolute_address_t opc) default: sprintf (buf, "???"); break; - } + } break; case _rel_byte: @@ -1055,19 +1049,18 @@ int dasm (char *buf, absolute_address_t opc) strcat (buf, "DP,"); if ((op & 0x06) == 0x06) strcat (buf, "D,"); - else - { + else { if (op & 0x04) strcat (buf, "B,"); if (op & 0x02) strcat (buf, "A,"); - } + } if (op & 0x01) strcat (buf, "CC,"); buf[strlen (buf) - 1] = '\0'; break; - } + } return pc - opc; } @@ -1096,27 +1089,23 @@ int load_map_file (const char *name) /* Try appending the suffix 'map' to the name of the program. */ sprintf (map_filename, "%s.map", name); fp = file_open (NULL, map_filename, "r"); - if (!fp) - { + if (!fp) { /* If that fails, try replacing any existing suffix. */ sprintf (map_filename, "%s", name); char *s = strrchr (map_filename, '.'); - if (s) - { + if (s) { sprintf (s+1, "map"); fp = file_open(NULL, map_filename, "r"); } - if (!fp) - { + if (!fp) { fprintf (stderr, "warning: no symbols for %s\n", name); return -1; } } printf ("Reading symbols from '%s'...\n", map_filename); - for (;;) - { + for (;;) { fgets (buf, sizeof(buf)-1, fp); if (feof (fp)) break; @@ -1150,27 +1139,23 @@ int load_image (const char *name) FILE *fp; fp = file_open(NULL, name, "r"); - if (fp == NULL) - { + if (fp == NULL) { printf("failed to open image file %s.\n", name); return 1; - } + } - if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) == 3) - { + if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) == 3) { rewind(fp); return load_s19(fp); - } - else if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) == 3) - { + } + else if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) == 3) { rewind(fp); return load_hex(fp); - } - else - { + } + else { printf ("unrecognised format in image file %s.\n", name); return 1; - } + } } int load_hex (FILE *fp) @@ -1179,45 +1164,38 @@ int load_hex (FILE *fp) int done = 1; int line = 0; - while (done != 0) - { + while (done != 0) { line++; - if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3) - { + if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3) { printf ("line %d: invalid hex record information.\n", line); break; - } + } checksum = count + (addr >> 8) + (addr & 0xff) + type; - switch (type) - { - case 0: - for (; count != 0; count--, addr++, checksum += data) - { - if (fscanf(fp, "%2x", &data)) - { + switch (type) { + case 0: /* data */ + for (; count != 0; count--, addr++, checksum += data) { + if (fscanf(fp, "%2x", &data)) { write8(addr, (UINT8) data); - } - else - { + } + else { printf("line %d: hex record data inconsistent with count field.\n", line); break; - } - } + } + } checksum = (-checksum) & 0xff; - if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) - { + if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) { printf("line %d: hex record checksum missing or invalid.\n", line); done = 0; break; - } + } fscanf(fp, "%*[\r\n]"); /* skip any form of line ending */ break; - case 1: + case 1: /* end of file */ checksum = (-checksum) & 0xff; if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) @@ -1230,8 +1208,8 @@ int load_hex (FILE *fp) printf("line %d: not supported hex type %d.\n", line, type); done = 0; break; - } - } + } + } (void) fclose (fp); return 0; @@ -1243,46 +1221,39 @@ int load_s19(FILE *fp) int done = 1; int line = 0; - while (done != 0) - { + while (done != 0) { line++; - if (fscanf(fp, "S%1x%2x%4x", &type, &count, &addr) != 3) - { + if (fscanf(fp, "S%1x%2x%4x", &type, &count, &addr) != 3) { printf("line %d: invalid S record information.\n", line); break; - } + } checksum = count + (addr >> 8) + (addr & 0xff); - switch (type) - { - case 1: - for (count -= 3; count != 0; count--, addr++, checksum += data) - { - if (fscanf (fp, "%2x", &data)) - { - write8 (addr, (UINT8) data); - } - else - { + switch (type) { + case 1: /* data */ + for (count -= 3; count != 0; count--, addr++, checksum += data) { + if (fscanf (fp, "%2x", &data)) { + write8 (addr, (UINT8) data); + } + else { printf ("line %d: S record data inconsistent with count field.\n", line); break; - } - } + } + } checksum = (~checksum) & 0xff; - if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) - { + if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) { printf ("line %d: S record checksum missing or invalid.\n", line); done = 0; break; - } + } fscanf (fp, "%*[\r\n]"); /* skip any form of line ending */ break; - case 9: + case 9: /* 16-bit start address */ checksum = (~checksum) & 0xff; if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) printf ("line %d: S record checksum missing or invalid.\n", line); @@ -1303,8 +1274,7 @@ int load_s19(FILE *fp) void monitor_call (unsigned int flags) { #ifdef CALL_STACK - if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1]) - { + if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1]) { current_function_call++; current_function_call->entry_point = get_pc (); current_function_call->flags = flags; @@ -1312,8 +1282,7 @@ void monitor_call (unsigned int flags) #endif #if 0 const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ())); - if (id) - { + if (id) { // printf ("In %s now\n", id); } #endif @@ -1322,15 +1291,13 @@ void monitor_call (unsigned int flags) void monitor_return (void) { #ifdef CALL_STACK - if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1]) - { + if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1]) { current_function_call--; return; } while ((current_function_call->flags & FC_TAIL_CALL) && - (current_function_call > fctab)) - { + (current_function_call > fctab)) { current_function_call--; } @@ -1383,7 +1350,8 @@ void monitor_init (void) { extern int debug_enabled; - fctab[0].entry_point = read16 (0xfffe); + /* PC has already been initialised to program entry point */ + fctab[0].entry_point = get_pc(); memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs)); current_function_call = &fctab[0]; From e33d870e4ebdd63133e10514cb627c49340697b3 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Wed, 7 Sep 2016 10:57:15 +0100 Subject: [PATCH 43/71] Add -e command-line argument to allow entry point (initial value of PC) to be defined without the need to enter debug mode. The monitor reset (re) command also takes an optional argument for the same purpose. Entry point can be a literal or symbolic (from the .map file). Cleaned-up lots of function prototypes to reduce the number of build warnings. --- 6809.c | 4 ++-- 6809.h | 36 +++++++++++++++++++++++++++++++++--- README | 23 ++++++++++++++++++++++- command.c | 26 +++++++++++++++++++++++++- imux.c | 2 +- machine.h | 14 ++++++++++++++ main.c | 18 ++++++++++-------- monitor.h | 3 +++ timer.c | 2 +- 9 files changed, 111 insertions(+), 17 deletions(-) diff --git a/6809.c b/6809.c index 8f70380..fd93f14 100644 --- a/6809.c +++ b/6809.c @@ -3015,7 +3015,7 @@ int cpu_execute (int cycles) return cpu_period; } -void cpu_reset (void) +void cpu_reset (unsigned newPC) { X = Y = S = U = A = B = DP = 0; H = N = OV = C = 0; @@ -3025,7 +3025,7 @@ void cpu_reset (void) MD = E = F = V = 0; #endif - change_pc (read16 (0xfffe)); + change_pc (newPC); cpu_is_running (); } diff --git a/6809.h b/6809.h index d5fc634..8b91c55 100644 --- a/6809.h +++ b/6809.h @@ -70,6 +70,14 @@ extern int dump_cycles_on_success; extern const char *prog_name; long get_elapsed_realtime (void); +void sim_error (const char *format, ...); +void sim_exit (uint8_t exit_code); +void print_regs (void); +void release_irq (unsigned int source); +void release_firq (unsigned int source); +void request_irq (unsigned int source); +void request_firq (unsigned int source); + /* Primitive read/write macros */ #define read8(addr) cpu_read8 (addr) @@ -89,7 +97,7 @@ long get_elapsed_realtime (void); /* 6809.c */ extern int cpu_quit; extern int cpu_execute (int); -extern void cpu_reset (void); +extern void cpu_reset (unsigned); extern unsigned get_a (void); extern unsigned get_b (void); @@ -102,6 +110,7 @@ extern unsigned get_u (void); extern unsigned get_pc (void); extern unsigned get_d (void); extern unsigned get_flags (void); +extern unsigned long get_cycles (void); extern void set_a (unsigned); extern void set_b (unsigned); extern void set_cc (unsigned); @@ -113,8 +122,22 @@ extern void set_u (unsigned); extern void set_pc (unsigned); extern void set_d (unsigned); -/* fileio.c */ +/* command.c */ +void keybuffering_defaults (void); +void keybuffering (int flag); +void command_periodic (void); +void command_exit_irq_hook (unsigned long cycles); +void command_insn_hook (void); +void command_init (void); +void command_read_hook (absolute_address_t addr); +void command_write_hook (absolute_address_t addr, U8 val); +int command_loop (void); +void print_current_insn (void); + +/* imux.c */ +void imux_assert (struct hw_device *dev, unsigned int sig); +/* fileio.c */ struct pathlist { int count; @@ -131,11 +154,16 @@ void file_close (FILE *fp); /* monitor.c */ extern int monitor_on; extern int check_break (void); -extern void monitor_init (void); +extern void monitor_init (void); extern int monitor6809 (void); extern int dasm (char *, absolute_address_t); extern int load_image (const char *); +int sizeof_file(FILE * file); +int load_map_file (const char *name); +int load_s19(FILE *fp); +int load_hex(FILE *fp); + #define MAX_STRINGSPACE 32000 #define MAX_SYMBOL_HASH 1009 @@ -182,8 +210,10 @@ extern struct symtab internal_symtab; extern struct symtab auto_symtab; struct symbol *sym_add (struct symtab *symtab, const char *name, unsigned long value, unsigned int type); +void sym_init (void); void sym_set (struct symtab *symtab, const char *name, unsigned long value, unsigned int type); int sym_find (struct symtab *symtab, const char *name, unsigned long *value, unsigned int type); +void symtab_print (struct symtab *symtab); const char *sym_lookup (struct symtab *symtab, unsigned long value); typedef void (*command_handler_t) (void); diff --git a/README b/README index 2d27bcc..7b95840 100644 --- a/README +++ b/README @@ -76,6 +76,22 @@ TODO : Would anyone be interested in a CoCo machine type? Faults +----------------------------------------------------------------- +Command-line arguments + +Use "-h" to get an abbreviated list of command-line arguments. +Notes on some follow: + +-e Can be used to set the initial value of the PC + (mnemonic: Entry point). This can be a numeric value or + a symbol from the map file (in which case it will need + a & prefix which in turn will need to be escaped to avoid + being interpreted by the shell). Eg: + -e 0x3000 + -e \&__start + +For an executable foo, any map file must be named foo.map + ----------------------------------------------------------------- Debugging @@ -184,8 +200,13 @@ regs Display the current value of the CPU registers. -re +re [] Reset the CPU/machine. + Optional specifies the initial PC value. If + omitted, initial PC value is fetched from 0xfffe + (the reset vector). Eg: + re 0x1000 + re &__start restore Restore machine state from a 'dump' file. NOT CURRENTLY diff --git a/command.c b/command.c index fa2da11..372050e 100644 --- a/command.c +++ b/command.c @@ -5,6 +5,7 @@ #include "machine.h" #include #include +#include #ifdef HAVE_TERMIOS_H # include #else @@ -12,6 +13,7 @@ #endif struct termios old_tio, new_tio; +int print_insn_long (absolute_address_t addr); typedef struct { @@ -752,6 +754,28 @@ char* getarg (void) /****************** Command Handlers ************************/ +void cpu_init (const char *arg) +{ + char eflag = 0; + unsigned long val; + + if (arg) { + val = eval (arg, &eflag); + if (eflag) + report_errors(eflag); + else + cpu_reset(val); + } + else + cpu_reset(read16(0xfffe)); /* reset vector */ +} + +void cmd_reset (void) +{ + char *arg = getarg (); + cpu_init(arg); +} + void cmd_print (void) { char *arg = getarg (); @@ -1253,7 +1277,7 @@ struct command_name { "fg", "foreground", cmd_continue, NULL }, { "q", "quit", cmd_quit, "Quit the simulator" }, - { "re", "reset", cpu_reset, + { "re", "reset", cmd_reset, "Reset the CPU" }, { "h", "help", cmd_help, "Display this help" }, diff --git a/imux.c b/imux.c index 371b2f2..4197ac3 100644 --- a/imux.c +++ b/imux.c @@ -21,7 +21,7 @@ /* The interrupt multiplexer */ #include -#include "machine.h" +#include "6809.h" #include "eon.h" struct imux diff --git a/machine.h b/machine.h index 05437d9..6258e26 100644 --- a/machine.h +++ b/machine.h @@ -157,5 +157,19 @@ struct hw_device *console_create (void); struct hw_device *disk_create (const char *backing_file, struct hw_device *ram_dev); void fault (unsigned int addr, unsigned char type); +void dump_machine(void); +void describe_machine (void); +void print_device_name (unsigned int devno); +void abs_write8 (absolute_address_t addr, U8 val); +U8 abs_read8 (absolute_address_t addr); +absolute_address_t to_absolute (unsigned long cpuaddr); +U8 cpu_read8 (unsigned int addr); +U16 cpu_read16 (unsigned int addr); +void cpu_write8 (unsigned int addr, U8 val); +void cpu_is_running (void); +void cpu_init (const char *arg); + +void machine_init (const char *machine_name, const char *boot_rom_file); +void machine_update (void); #endif /* _M6809_MACHINE_H */ diff --git a/main.c b/main.c index 61d655d..ed20b88 100644 --- a/main.c +++ b/main.c @@ -21,6 +21,7 @@ #include +#include #include "6809.h" /* The total number of cycles that have executed */ @@ -64,7 +65,7 @@ static int binary = 0; char *exename; const char *machine_name = "simple"; - +const char *entry_addr = NULL; const char *prog_name = NULL; FILE *stat_file = NULL; @@ -174,9 +175,11 @@ struct option NO_NEG, NO_ARG, NULL, 0, 0, do_help }, { 'b', "binary", "", NO_NEG, NO_ARG, &binary, 1, NULL, NULL }, + { 'e', "entry", "Entry point (address or symbol name)", + NO_NEG, HAS_ARG, NULL, 0, &entry_addr, NULL }, { 'M', "mhz", "", NO_NEG, HAS_ARG }, - { '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" }, - { '-', "68b09", "Emulate the 68B09 variation (2Mhz)" }, + { '-', "68a09", "Emulate the 68A09 variation (1.5MHz)" }, + { '-', "68b09", "Emulate the 68B09 variation (2MHz)" }, { 'R', "realtime", "Limit simulation speed to match realtime", HAS_NEG, NO_ARG, &machine_realtime, 0, NULL, NULL }, { 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically", @@ -367,14 +370,13 @@ main (int argc, char *argv[]) if (prog_name) load_map_file (prog_name); - /* Enable debugging if no executable given yet. */ + /* Force debugging to be on if no executable given yet. */ if (!prog_name) { debug_enabled = 1; } - else { - /* OK, ready to run. Reset the CPU first. */ - cpu_reset (); - } + + /* OK, ready to run. Reset the CPU first. */ + cpu_init (entry_addr); monitor_init (); command_init (); diff --git a/monitor.h b/monitor.h index a93091c..cca71b0 100644 --- a/monitor.h +++ b/monitor.h @@ -72,9 +72,12 @@ struct function_call { void add_named_symbol (const char *id, target_addr_t value, const char *filename); struct x_symbol * find_symbol (target_addr_t value); + void monitor_branch (void); void monitor_call (unsigned int flags); void monitor_return (void); +void monitor_backtrace (void); + const char * monitor_addr_name (target_addr_t addr); const char * absolute_addr_name (unsigned long addr); diff --git a/timer.c b/timer.c index db6a09a..960f898 100644 --- a/timer.c +++ b/timer.c @@ -20,7 +20,7 @@ #include #include -#include "machine.h" +#include "6809.h" /* A hardware timer counts CPU cycles and can generate interrupts periodically. */ struct hwtimer From fc4e69f8c5f4a560b8b4a1618bc0fb3163995099 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Thu, 8 Sep 2016 16:11:28 +0100 Subject: [PATCH 44/71] if initial PC came from symbol table entry it was really an absolute value and the simulation was going to hyperspace. Mask off PC to ensure that it is 16-bit. --- 6809.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/6809.c b/6809.c index fd93f14..d9b1657 100644 --- a/6809.c +++ b/6809.c @@ -3025,7 +3025,7 @@ void cpu_reset (unsigned newPC) MD = E = F = V = 0; #endif - change_pc (newPC); + change_pc (0xffff & newPC); cpu_is_running (); } @@ -3040,7 +3040,7 @@ void print_regs (void) if (get_cc() & H_FLAG) flags[5] = 'H'; if (get_cc() & F_FLAG) flags[6] = 'F'; if (get_cc() & E_FLAG) flags[7] = 'E'; - + /* printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", get_x(), read16(get_x()), get_y(), read16(get_y()) ); printf ("PC: 0x%04X [PC]: 0x%04X\n", @@ -3050,4 +3050,14 @@ void print_regs (void) printf ("DP: 0x%02X\n", get_dp() ); printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", get_a(), get_b(), read16(get_d()), flags ); + */ + printf (" X: 0x%04X Y: 0x%04X ", + get_x(), get_y()); + printf ("PC: 0x%04X [PC]: 0x%04X\n", + get_pc(), read16(get_pc()) ); + printf (" U: 0x%04X S: 0x%04X ", + get_u(), get_s() ); + printf ("DP: 0x%02X\n", get_dp() ); + printf (" A: 0x%02X B: 0x%02X CC: %s\n", + get_a(), get_b(), flags ); } From 8d166852bb760340f325e469052bd2a23d2585e1 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 9 Sep 2016 15:46:06 +0100 Subject: [PATCH 45/71] no need to initialise cpu_quit here because it is initialised in main. --- 6809.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/6809.c b/6809.c index d9b1657..020d91f 100644 --- a/6809.c +++ b/6809.c @@ -43,7 +43,7 @@ unsigned long irq_start_time; unsigned ea = 0; long cpu_clk = 0; long cpu_period = 0; -int cpu_quit = 1; +int cpu_quit; unsigned int irqs_pending = 0; unsigned int firqs_pending = 0; unsigned int cc_changed = 0; @@ -112,7 +112,7 @@ void sim_error (const char *format, ...) monitor_on = 1; else { keybuffering (1); - exit (2); + exit (0); // exit (2); } } From e5fa48637d85aa2978eb596cda9374e337670c76 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Fri, 9 Sep 2016 16:10:47 +0100 Subject: [PATCH 46/71] Tweak the watchpoint code to make it more consistent with the breakpoint code. Revise README to show that the watchpoint options can be combined. --- README | 5 +++++ command.c | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/README b/README index 7b95840..67551e9 100644 --- a/README +++ b/README @@ -120,6 +120,11 @@ wa - break and report on each write to this address but only if the write data ANDed with the mask value is non-zero. + wa 0x1200 if + wa 0x1200 if $s==02:0x0043 + - break on write to this address if the S register has + the value shown. + Combinations of mask/print/if are allowed. rwa Set a watchpoint on READ from the given address. See diff --git a/command.c b/command.c index 372050e..ef01b7b 100644 --- a/command.c +++ b/command.c @@ -843,22 +843,22 @@ void cmd_break (void) if (!arg) return; - unsigned long val = eval_mem (arg, LVALUE, &eflag); + absolute_address_t addr = eval_mem (arg, LVALUE, &eflag); if (eflag) report_errors(eflag); else { breakpoint_t *br = brkalloc (); - br->addr = val; + br->addr = addr; br->on_execute = 1; arg = getarg (); if (!arg); else if (!strcmp (arg, "if")) { - br->conditional = 1; arg = getarg (); + br->conditional = 1; strcpy (br->condition, arg); } else if (!strcmp (arg, "ignore")) From 41307e1fbada0b0d2eafff623d7316be81f69398 Mon Sep 17 00:00:00 2001 From: Neal Andrew Crook Date: Tue, 13 Sep 2016 11:54:09 +0100 Subject: [PATCH 47/71] revert change to register printout. Always exit with success - for now. Need this so that I can terminate the simulator on reaching a cycle limit. Want a cleaner way of doing this in order to run the emulator in a scripted loop for test4gcc6809. --- 6809.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/6809.c b/6809.c index 020d91f..d179c67 100644 --- a/6809.c +++ b/6809.c @@ -112,6 +112,8 @@ void sim_error (const char *format, ...) monitor_on = 1; else { keybuffering (1); + // [NAC HACK 2016Sep13] temp. Need to exit with success for + // now so that I can run testgcc scripts. exit (0); // exit (2); } } @@ -3040,7 +3042,7 @@ void print_regs (void) if (get_cc() & H_FLAG) flags[5] = 'H'; if (get_cc() & F_FLAG) flags[6] = 'F'; if (get_cc() & E_FLAG) flags[7] = 'E'; - /* + printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", get_x(), read16(get_x()), get_y(), read16(get_y()) ); printf ("PC: 0x%04X [PC]: 0x%04X\n", @@ -3050,14 +3052,4 @@ void print_regs (void) printf ("DP: 0x%02X\n", get_dp() ); printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", get_a(), get_b(), read16(get_d()), flags ); - */ - printf (" X: 0x%04X Y: 0x%04X ", - get_x(), get_y()); - printf ("PC: 0x%04X [PC]: 0x%04X\n", - get_pc(), read16(get_pc()) ); - printf (" U: 0x%04X S: 0x%04X ", - get_u(), get_s() ); - printf ("DP: 0x%02X\n", get_dp() ); - printf (" A: 0x%02X B: 0x%02X CC: %s\n", - get_a(), get_b(), flags ); } From f39131a51df5f8ec4afb2b4985fcfdebcee72201 Mon Sep 17 00:00:00 2001 From: nealcrook Date: Fri, 21 Oct 2016 22:48:45 +0100 Subject: [PATCH 48/71] force PC to be truncated to 16-bits to avoid it goinf to large negative value on branch. Don't know why I never saw this before.. nasty. --- 6809.c | 68 +++++++++++++++++++++++++++++++++++----------------------- 6809.h | 40 +++++++++++++++++----------------- 2 files changed, 61 insertions(+), 47 deletions(-) diff --git a/6809.c b/6809.c index 8f70380..02e79a2 100644 --- a/6809.c +++ b/6809.c @@ -172,7 +172,10 @@ static inline void change_pc (unsigned newPC) fprintf (stderr, "-> %s\n", monitor_addr_name (newPC)); } #endif - PC = newPC; + PC = newPC & 0xffff; /* [NAC HACK 2016Oct21] stop PC from going out of range. Crude. + why have I not seen this problem before? Did I introduce this + bug as a side-effect of another change? + */ } static inline unsigned imm_byte (void) @@ -389,47 +392,47 @@ static void extended (void) /* external register functions */ -unsigned get_a (void) +U8 get_a (void) { return A; } -unsigned get_b (void) +U8 get_b (void) { return B; } -unsigned get_dp (void) +U8 get_dp (void) { return DP >> 8; } -unsigned get_x (void) +U16 get_x (void) { return X; } -unsigned get_y (void) +U16 get_y (void) { return Y; } -unsigned get_s (void) +U16 get_s (void) { return S; } -unsigned get_u (void) +U16 get_u (void) { return U; } -unsigned get_pc (void) +U16 get_pc (void) { return PC & 0xffff; } -unsigned get_d (void) +U16 get_d (void) { return (A << 8) | B; } @@ -476,49 +479,49 @@ unsigned get_md (void) } #endif -void set_a (unsigned val) +void set_a (U8 val) { A = val & 0xff; } -void set_b (unsigned val) +void set_b (U8 val) { B = val & 0xff; } -void set_dp (unsigned val) +void set_dp (U8 val) { DP = (val & 0xff) << 8; } -void set_x (unsigned val) +void set_x (U16 val) { X = val & 0xffff; } -void set_y (unsigned val) +void set_y (U16 val) { Y = val & 0xffff; } -void set_s (unsigned val) +void set_s (U16 val) { S = val & 0xffff; check_stack (); } -void set_u (unsigned val) +void set_u (U16 val) { U = val & 0xffff; } -void set_pc (unsigned val) +void set_pc (U16 val) { PC = val & 0xffff; check_pc (); } -void set_d (unsigned val) +void set_d (U16 val) { A = (val >> 8) & 0xff; B = val & 0xff; @@ -564,7 +567,7 @@ void set_md (unsigned val) /* handle condition code register */ -unsigned get_cc (void) +U8 get_cc (void) { unsigned res = EFI & (E_FLAG | F_FLAG | I_FLAG); @@ -582,7 +585,7 @@ unsigned get_cc (void) return res; } -void set_cc (unsigned arg) +void set_cc (U8 arg) { EFI = arg & (E_FLAG | F_FLAG | I_FLAG); H = (arg & H_FLAG ? 0x10 : 0); @@ -1880,11 +1883,11 @@ int cpu_execute (int cycles) case 0x8b: /* ADDW */ break; #endif - case 0x8c: + case 0x8c: /* CMPY imm */ cpu_clk -= 5; cmp16 (Y, imm_word ()); break; - case 0x8e: + case 0x8e: /* LDY imm */ cpu_clk -= 4; Y = ld16 (imm_word ()); break; @@ -3041,13 +3044,24 @@ void print_regs (void) if (get_cc() & F_FLAG) flags[6] = 'F'; if (get_cc() & E_FLAG) flags[7] = 'E'; - printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", - get_x(), read16(get_x()), get_y(), read16(get_y()) ); + /* printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", + get_x(), 0xffff & read16(get_x()), get_y(), 0xffff & read16(get_y()) ); printf ("PC: 0x%04X [PC]: 0x%04X\n", get_pc(), read16(get_pc()) ); printf (" U: 0x%04X [U]: 0x%04X S: 0x%04X [S]: 0x%04X ", - get_u(), read16(get_u()), get_s(), read16(get_s()) ); + get_u(), 0xffff & read16(get_u()), get_s(), 0xffff & read16(get_s()) ); + printf ("DP: 0x%02X\n", get_dp() ); + printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", + get_a(), get_b(), 0xffff & read16(get_d()), flags ); + */ + + printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", + get_x(), 0xffff & 0, get_y(), 0xffff & 0 ); + printf ("PC: 0x%04X [PC]: 0x%04X\n", + get_pc(), 0 ); + printf (" U: 0x%04X [U]: 0x%04X S: 0x%04X [S]: 0x%04X ", + get_u(), 0xffff & 0, get_s(), 0xffff & 0 ); printf ("DP: 0x%02X\n", get_dp() ); printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", - get_a(), get_b(), read16(get_d()), flags ); + get_a(), get_b(), 0xffff & 0, flags ); } diff --git a/6809.h b/6809.h index d5fc634..3e5ccb8 100644 --- a/6809.h +++ b/6809.h @@ -91,27 +91,27 @@ extern int cpu_quit; extern int cpu_execute (int); extern void cpu_reset (void); -extern unsigned get_a (void); -extern unsigned get_b (void); -extern unsigned get_cc (void); -extern unsigned get_dp (void); -extern unsigned get_x (void); -extern unsigned get_y (void); -extern unsigned get_s (void); -extern unsigned get_u (void); -extern unsigned get_pc (void); -extern unsigned get_d (void); +extern U8 get_a (void); +extern U8 get_b (void); +extern U8 get_cc (void); +extern U8 get_dp (void); +extern U16 get_x (void); +extern U16 get_y (void); +extern U16 get_s (void); +extern U16 get_u (void); +extern U16 get_pc (void); +extern U16 get_d (void); extern unsigned get_flags (void); -extern void set_a (unsigned); -extern void set_b (unsigned); -extern void set_cc (unsigned); -extern void set_dp (unsigned); -extern void set_x (unsigned); -extern void set_y (unsigned); -extern void set_s (unsigned); -extern void set_u (unsigned); -extern void set_pc (unsigned); -extern void set_d (unsigned); +extern void set_a (U8); +extern void set_b (U8); +extern void set_cc (U8); +extern void set_dp (U8); +extern void set_x (U16); +extern void set_y (U16); +extern void set_s (U16); +extern void set_u (U16); +extern void set_pc (U16); +extern void set_d (U16); /* fileio.c */ From ef0d184e0d3a7e2903b9d624e6366c6325010554 Mon Sep 17 00:00:00 2001 From: nealcrook Date: Fri, 21 Oct 2016 23:09:04 +0100 Subject: [PATCH 49/71] Revert "Merge branch 'trunk' of https://github.com/nealcrook/exec09 into trunk" This reverts commit 0730ad94e3f888fc89bb1a146f8c1450f39b0a00, reversing changes made to f39131a51df5f8ec4afb2b4985fcfdebcee72201. --- 6809.c | 10 ++-- 6809.h | 36 ++----------- README | 28 +--------- command.c | 32 ++--------- imux.c | 2 +- machine.h | 14 ----- main.c | 113 +++++++++++++++++++++++--------------- monitor.c | 158 ++++++++++++++++++++++++++++++++---------------------- monitor.h | 3 -- timer.c | 2 +- 10 files changed, 180 insertions(+), 218 deletions(-) diff --git a/6809.c b/6809.c index 667fb2c..02e79a2 100644 --- a/6809.c +++ b/6809.c @@ -43,7 +43,7 @@ unsigned long irq_start_time; unsigned ea = 0; long cpu_clk = 0; long cpu_period = 0; -int cpu_quit; +int cpu_quit = 1; unsigned int irqs_pending = 0; unsigned int firqs_pending = 0; unsigned int cc_changed = 0; @@ -112,9 +112,7 @@ void sim_error (const char *format, ...) monitor_on = 1; else { keybuffering (1); - // [NAC HACK 2016Sep13] temp. Need to exit with success for - // now so that I can run testgcc scripts. - exit (0); // exit (2); + exit (2); } } @@ -3020,7 +3018,7 @@ int cpu_execute (int cycles) return cpu_period; } -void cpu_reset (unsigned newPC) +void cpu_reset (void) { X = Y = S = U = A = B = DP = 0; H = N = OV = C = 0; @@ -3030,7 +3028,7 @@ void cpu_reset (unsigned newPC) MD = E = F = V = 0; #endif - change_pc (0xffff & newPC); + change_pc (read16 (0xfffe)); cpu_is_running (); } diff --git a/6809.h b/6809.h index 347f9e3..3e5ccb8 100644 --- a/6809.h +++ b/6809.h @@ -70,14 +70,6 @@ extern int dump_cycles_on_success; extern const char *prog_name; long get_elapsed_realtime (void); -void sim_error (const char *format, ...); -void sim_exit (uint8_t exit_code); -void print_regs (void); -void release_irq (unsigned int source); -void release_firq (unsigned int source); -void request_irq (unsigned int source); -void request_firq (unsigned int source); - /* Primitive read/write macros */ #define read8(addr) cpu_read8 (addr) @@ -97,7 +89,7 @@ void request_firq (unsigned int source); /* 6809.c */ extern int cpu_quit; extern int cpu_execute (int); -extern void cpu_reset (unsigned); +extern void cpu_reset (void); extern U8 get_a (void); extern U8 get_b (void); @@ -110,7 +102,6 @@ extern U16 get_u (void); extern U16 get_pc (void); extern U16 get_d (void); extern unsigned get_flags (void); - extern void set_a (U8); extern void set_b (U8); extern void set_cc (U8); @@ -122,22 +113,8 @@ extern void set_u (U16); extern void set_pc (U16); extern void set_d (U16); -/* command.c */ -void keybuffering_defaults (void); -void keybuffering (int flag); -void command_periodic (void); -void command_exit_irq_hook (unsigned long cycles); -void command_insn_hook (void); -void command_init (void); -void command_read_hook (absolute_address_t addr); -void command_write_hook (absolute_address_t addr, U8 val); -int command_loop (void); -void print_current_insn (void); - -/* imux.c */ -void imux_assert (struct hw_device *dev, unsigned int sig); - /* fileio.c */ + struct pathlist { int count; @@ -154,16 +131,11 @@ void file_close (FILE *fp); /* monitor.c */ extern int monitor_on; extern int check_break (void); -extern void monitor_init (void); +extern void monitor_init (void); extern int monitor6809 (void); extern int dasm (char *, absolute_address_t); extern int load_image (const char *); -int sizeof_file(FILE * file); -int load_map_file (const char *name); -int load_s19(FILE *fp); -int load_hex(FILE *fp); - #define MAX_STRINGSPACE 32000 #define MAX_SYMBOL_HASH 1009 @@ -210,10 +182,8 @@ extern struct symtab internal_symtab; extern struct symtab auto_symtab; struct symbol *sym_add (struct symtab *symtab, const char *name, unsigned long value, unsigned int type); -void sym_init (void); void sym_set (struct symtab *symtab, const char *name, unsigned long value, unsigned int type); int sym_find (struct symtab *symtab, const char *name, unsigned long *value, unsigned int type); -void symtab_print (struct symtab *symtab); const char *sym_lookup (struct symtab *symtab, unsigned long value); typedef void (*command_handler_t) (void); diff --git a/README b/README index 67551e9..2d27bcc 100644 --- a/README +++ b/README @@ -76,22 +76,6 @@ TODO : Would anyone be interested in a CoCo machine type? Faults ------------------------------------------------------------------ -Command-line arguments - -Use "-h" to get an abbreviated list of command-line arguments. -Notes on some follow: - --e Can be used to set the initial value of the PC - (mnemonic: Entry point). This can be a numeric value or - a symbol from the map file (in which case it will need - a & prefix which in turn will need to be escaped to avoid - being interpreted by the shell). Eg: - -e 0x3000 - -e \&__start - -For an executable foo, any map file must be named foo.map - ----------------------------------------------------------------- Debugging @@ -120,11 +104,6 @@ wa - break and report on each write to this address but only if the write data ANDed with the mask value is non-zero. - wa 0x1200 if - wa 0x1200 if $s==02:0x0043 - - break on write to this address if the S register has - the value shown. - Combinations of mask/print/if are allowed. rwa Set a watchpoint on READ from the given address. See @@ -205,13 +184,8 @@ regs Display the current value of the CPU registers. -re [] +re Reset the CPU/machine. - Optional specifies the initial PC value. If - omitted, initial PC value is fetched from 0xfffe - (the reset vector). Eg: - re 0x1000 - re &__start restore Restore machine state from a 'dump' file. NOT CURRENTLY diff --git a/command.c b/command.c index ef01b7b..fa2da11 100644 --- a/command.c +++ b/command.c @@ -5,7 +5,6 @@ #include "machine.h" #include #include -#include #ifdef HAVE_TERMIOS_H # include #else @@ -13,7 +12,6 @@ #endif struct termios old_tio, new_tio; -int print_insn_long (absolute_address_t addr); typedef struct { @@ -754,28 +752,6 @@ char* getarg (void) /****************** Command Handlers ************************/ -void cpu_init (const char *arg) -{ - char eflag = 0; - unsigned long val; - - if (arg) { - val = eval (arg, &eflag); - if (eflag) - report_errors(eflag); - else - cpu_reset(val); - } - else - cpu_reset(read16(0xfffe)); /* reset vector */ -} - -void cmd_reset (void) -{ - char *arg = getarg (); - cpu_init(arg); -} - void cmd_print (void) { char *arg = getarg (); @@ -843,22 +819,22 @@ void cmd_break (void) if (!arg) return; - absolute_address_t addr = eval_mem (arg, LVALUE, &eflag); + unsigned long val = eval_mem (arg, LVALUE, &eflag); if (eflag) report_errors(eflag); else { breakpoint_t *br = brkalloc (); - br->addr = addr; + br->addr = val; br->on_execute = 1; arg = getarg (); if (!arg); else if (!strcmp (arg, "if")) { - arg = getarg (); br->conditional = 1; + arg = getarg (); strcpy (br->condition, arg); } else if (!strcmp (arg, "ignore")) @@ -1277,7 +1253,7 @@ struct command_name { "fg", "foreground", cmd_continue, NULL }, { "q", "quit", cmd_quit, "Quit the simulator" }, - { "re", "reset", cmd_reset, + { "re", "reset", cpu_reset, "Reset the CPU" }, { "h", "help", cmd_help, "Display this help" }, diff --git a/imux.c b/imux.c index 4197ac3..371b2f2 100644 --- a/imux.c +++ b/imux.c @@ -21,7 +21,7 @@ /* The interrupt multiplexer */ #include -#include "6809.h" +#include "machine.h" #include "eon.h" struct imux diff --git a/machine.h b/machine.h index 6258e26..05437d9 100644 --- a/machine.h +++ b/machine.h @@ -157,19 +157,5 @@ struct hw_device *console_create (void); struct hw_device *disk_create (const char *backing_file, struct hw_device *ram_dev); void fault (unsigned int addr, unsigned char type); -void dump_machine(void); -void describe_machine (void); -void print_device_name (unsigned int devno); -void abs_write8 (absolute_address_t addr, U8 val); -U8 abs_read8 (absolute_address_t addr); -absolute_address_t to_absolute (unsigned long cpuaddr); -U8 cpu_read8 (unsigned int addr); -U16 cpu_read16 (unsigned int addr); -void cpu_write8 (unsigned int addr, U8 val); -void cpu_is_running (void); -void cpu_init (const char *arg); - -void machine_init (const char *machine_name, const char *boot_rom_file); -void machine_update (void); #endif /* _M6809_MACHINE_H */ diff --git a/main.c b/main.c index ed20b88..3785d69 100644 --- a/main.c +++ b/main.c @@ -8,12 +8,12 @@ * 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. - * + * * GCC6809 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 GCC6809; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA @@ -21,7 +21,6 @@ #include -#include #include "6809.h" /* The total number of cycles that have executed */ @@ -65,7 +64,7 @@ static int binary = 0; char *exename; const char *machine_name = "simple"; -const char *entry_addr = NULL; + const char *prog_name = NULL; FILE *stat_file = NULL; @@ -130,7 +129,8 @@ idle_loop (void) last_cycles = cycles; total_ms_elapsed += sim_ms; - if (total_ms_elapsed > 100) { + if (total_ms_elapsed > 100) + { total_ms_elapsed -= 100; if (machine->periodic) machine->periodic (); @@ -139,7 +139,8 @@ idle_loop (void) delay = sim_ms - real_ms; cumulative_delay += delay; - if (cumulative_delay > 0) { + if (cumulative_delay > 0) + { usleep (50 * 1000UL); cumulative_delay -= 50; } @@ -175,11 +176,9 @@ struct option NO_NEG, NO_ARG, NULL, 0, 0, do_help }, { 'b', "binary", "", NO_NEG, NO_ARG, &binary, 1, NULL, NULL }, - { 'e', "entry", "Entry point (address or symbol name)", - NO_NEG, HAS_ARG, NULL, 0, &entry_addr, NULL }, { 'M', "mhz", "", NO_NEG, HAS_ARG }, - { '-', "68a09", "Emulate the 68A09 variation (1.5MHz)" }, - { '-', "68b09", "Emulate the 68B09 variation (2MHz)" }, + { '-', "68a09", "Emulate the 68A09 variation (1.5Mhz)" }, + { '-', "68b09", "Emulate the 68B09 variation (2Mhz)" }, { 'R', "realtime", "Limit simulation speed to match realtime", HAS_NEG, NO_ARG, &machine_realtime, 0, NULL, NULL }, { 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically", @@ -209,8 +208,10 @@ do_help (const char *arg __attribute__((unused))) printf ("Motorola 6809 Simulator Version %s\n", PACKAGE_VERSION); printf ("m6809-run [options] [program]\n\n"); printf ("Options:\n"); - while (opt->o_long != NULL) { - if (opt->help) { + while (opt->o_long != NULL) + { + if (opt->help) + { if (opt->o_short == '-') printf (" --%-16.16s %s\n", opt->o_long, opt->help); else @@ -238,36 +239,45 @@ process_option (struct option *opt, const char *arg) { int rc; //printf ("Processing option '%s'\n", opt->o_long); - if (opt->takes_arg) { - if (!arg) { + if (opt->takes_arg) + { + if (!arg) + { //printf (" Takes argument but none given.\n"); rc = 0; } - else { - if (opt->int_value) { + else + { + if (opt->int_value) + { *(opt->int_value) = strtoul (arg, NULL, 0); //printf (" Integer argument '%d' taken.\n", *(opt->int_value)); } - else if (opt->string_value) { + else if (opt->string_value) + { *(opt->string_value) = arg; //printf (" String argument '%s' taken.\n", *(opt->string_value)); } rc = 1; } } - else { - if (arg) { + else + { + if (arg) + { //printf (" Takes no argument but one given, ignored.\n"); } - if (opt->int_value) { + if (opt->int_value) + { *(opt->int_value) = opt->default_value; //printf (" Integer argument 1 implied.\n"); } rc = 0; } - if (opt->handler) { + if (opt->handler) + { rc = opt->handler (arg); //printf (" Handler called, rc=%d\n", rc); } @@ -294,17 +304,22 @@ parse_args (int argc, char *argv[]) struct option *opt; next_arg: - while (argn < argc) { + while (argn < argc) + { char *arg = argv[argn]; - if (arg[0] == '-') { - if (arg[1] == '-') { + if (arg[0] == '-') + { + if (arg[1] == '-') + { char *rest = strchr (arg+2, '='); if (rest) *rest++ = '\0'; opt = option_table; - while (opt->o_long != NULL) { - if (!strcmp (opt->o_long, arg+2)) { + while (opt->o_long != NULL) + { + if (!strcmp (opt->o_long, arg+2)) + { argn++; (void)process_option (opt, rest); goto next_arg; @@ -313,10 +328,13 @@ parse_args (int argc, char *argv[]) } printf ("long option '%s' not recognized.\n", arg+2); } - else { + else + { opt = option_table; - while (opt->o_long != NULL) { - if (opt->o_short == arg[1]) { + while (opt->o_long != NULL) + { + if (opt->o_short == arg[1]) + { argn++; if (process_option (opt, argv[argn])) argn++; @@ -328,7 +346,8 @@ parse_args (int argc, char *argv[]) } argn++; } - else { + else + { process_plain_argument (argv[argn++]); } } @@ -354,10 +373,12 @@ main (int argc, char *argv[]) sym_init (); - if (binary) { + if (binary) + { machine_init (machine_name, prog_name); } - else { + else + { /* The machine loader cannot deal with image files, so initialize the machine first, passing it a NULL filename, then load the image file afterwards. */ @@ -370,13 +391,16 @@ main (int argc, char *argv[]) if (prog_name) load_map_file (prog_name); - /* Force debugging to be on if no executable given yet. */ - if (!prog_name) { + /* Enable debugging if no executable given yet. */ + if (!prog_name) + { debug_enabled = 1; } - - /* OK, ready to run. Reset the CPU first. */ - cpu_init (entry_addr); + else + { + /* OK, ready to run. Reset the CPU first. */ + cpu_reset (); + } monitor_init (); command_init (); @@ -387,8 +411,10 @@ main (int argc, char *argv[]) * If no IRQs or FIRQs are enabled, we can just call cpu_execute() * and let it run for a long time; otherwise, we need to come back * here periodically and do the interrupt handling. */ - for (cpu_quit = 1; cpu_quit != 0;) { - if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) { + for (cpu_quit = 1; cpu_quit != 0;) + { + if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) + { /* Simulate some CPU time, either 1ms worth or up to the next possible IRQ */ total += cpu_execute (mhz * 1024); @@ -396,14 +422,16 @@ main (int argc, char *argv[]) /* Call each device that needs periodic processing. */ machine_update (); } - else { + else + { total += cpu_execute (cycles_per_irq); /* TODO - this assumes periodic interrupts (WPC) */ request_irq (0); { /* TODO - FIRQ frequency not handled yet */ static int firq_freq = 0; - if (++firq_freq == 8) { + if (++firq_freq == 8) + { request_firq (0); firq_freq = 0; } @@ -413,7 +441,8 @@ main (int argc, char *argv[]) idle_loop (); /* Check for a rogue program that won't end */ - if ((max_cycles > 0) && (total > max_cycles)) { + if ((max_cycles > 0) && (total > max_cycles)) + { sim_error ("maximum cycle count exceeded at %s\n", monitor_addr_name (get_pc ())); } diff --git a/monitor.c b/monitor.c index b670027..1d94ef3 100644 --- a/monitor.c +++ b/monitor.c @@ -897,25 +897,29 @@ int dasm (char *buf, absolute_address_t opc) op = fetch8(); - if (op == 0x10) { + if (op == 0x10) + { op = fetch8(); am = codes10[op].mode; op = codes10[op].code; - } - else if (op == 0x11) { + } + else if (op == 0x11) + { op = fetch8(); am = codes11[op].mode; op = codes11[op].code; - } - else { + } + else + { am = codes[op].mode; op = codes[op].code; - } + } op_str = (char *) mne[op]; buf += sprintf (buf, "%-6.6s", op_str); - switch (am) { + switch (am) + { case _illegal: sprintf (buf, "???"); break; @@ -938,12 +942,14 @@ int dasm (char *buf, absolute_address_t opc) op = fetch8 (); R = index_reg[(op >> 5) & 0x3]; - if ((op & 0x80) == 0) { + if ((op & 0x80) == 0) + { sprintf (buf, "%s,%c", off4[op & 0x1f], R); break; - } + } - switch (op & 0x1f) { + switch (op & 0x1f) + { case 0x00: sprintf (buf, ",%c+", R); break; @@ -1016,7 +1022,7 @@ int dasm (char *buf, absolute_address_t opc) default: sprintf (buf, "???"); break; - } + } break; case _rel_byte: @@ -1049,18 +1055,19 @@ int dasm (char *buf, absolute_address_t opc) strcat (buf, "DP,"); if ((op & 0x06) == 0x06) strcat (buf, "D,"); - else { + else + { if (op & 0x04) strcat (buf, "B,"); if (op & 0x02) strcat (buf, "A,"); - } + } if (op & 0x01) strcat (buf, "CC,"); buf[strlen (buf) - 1] = '\0'; break; - } + } return pc - opc; } @@ -1089,23 +1096,27 @@ int load_map_file (const char *name) /* Try appending the suffix 'map' to the name of the program. */ sprintf (map_filename, "%s.map", name); fp = file_open (NULL, map_filename, "r"); - if (!fp) { + if (!fp) + { /* If that fails, try replacing any existing suffix. */ sprintf (map_filename, "%s", name); char *s = strrchr (map_filename, '.'); - if (s) { + if (s) + { sprintf (s+1, "map"); fp = file_open(NULL, map_filename, "r"); } - if (!fp) { + if (!fp) + { fprintf (stderr, "warning: no symbols for %s\n", name); return -1; } } printf ("Reading symbols from '%s'...\n", map_filename); - for (;;) { + for (;;) + { fgets (buf, sizeof(buf)-1, fp); if (feof (fp)) break; @@ -1139,23 +1150,27 @@ int load_image (const char *name) FILE *fp; fp = file_open(NULL, name, "r"); - if (fp == NULL) { + if (fp == NULL) + { printf("failed to open image file %s.\n", name); return 1; - } + } - if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) == 3) { + if (fscanf (fp, "S%1x%2x%4x", &type, &count, &addr) == 3) + { rewind(fp); return load_s19(fp); - } - else if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) == 3) { + } + else if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) == 3) + { rewind(fp); return load_hex(fp); - } - else { + } + else + { printf ("unrecognised format in image file %s.\n", name); return 1; - } + } } int load_hex (FILE *fp) @@ -1164,38 +1179,45 @@ int load_hex (FILE *fp) int done = 1; int line = 0; - while (done != 0) { + while (done != 0) + { line++; - if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3) { + if (fscanf (fp, ":%2x%4x%2x", &count, &addr, &type) != 3) + { printf ("line %d: invalid hex record information.\n", line); break; - } + } checksum = count + (addr >> 8) + (addr & 0xff) + type; - switch (type) { - case 0: /* data */ - for (; count != 0; count--, addr++, checksum += data) { - if (fscanf(fp, "%2x", &data)) { + switch (type) + { + case 0: + for (; count != 0; count--, addr++, checksum += data) + { + if (fscanf(fp, "%2x", &data)) + { write8(addr, (UINT8) data); - } - else { + } + else + { printf("line %d: hex record data inconsistent with count field.\n", line); break; - } - } + } + } checksum = (-checksum) & 0xff; - if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) { + if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) + { printf("line %d: hex record checksum missing or invalid.\n", line); done = 0; break; - } + } fscanf(fp, "%*[\r\n]"); /* skip any form of line ending */ break; - case 1: /* end of file */ + case 1: checksum = (-checksum) & 0xff; if ( (fscanf(fp, "%2x", &data) != 1) || (data != checksum) ) @@ -1208,8 +1230,8 @@ int load_hex (FILE *fp) printf("line %d: not supported hex type %d.\n", line, type); done = 0; break; - } - } + } + } (void) fclose (fp); return 0; @@ -1221,39 +1243,46 @@ int load_s19(FILE *fp) int done = 1; int line = 0; - while (done != 0) { + while (done != 0) + { line++; - if (fscanf(fp, "S%1x%2x%4x", &type, &count, &addr) != 3) { + if (fscanf(fp, "S%1x%2x%4x", &type, &count, &addr) != 3) + { printf("line %d: invalid S record information.\n", line); break; - } + } checksum = count + (addr >> 8) + (addr & 0xff); - switch (type) { - case 1: /* data */ - for (count -= 3; count != 0; count--, addr++, checksum += data) { - if (fscanf (fp, "%2x", &data)) { - write8 (addr, (UINT8) data); - } - else { + switch (type) + { + case 1: + for (count -= 3; count != 0; count--, addr++, checksum += data) + { + if (fscanf (fp, "%2x", &data)) + { + write8 (addr, (UINT8) data); + } + else + { printf ("line %d: S record data inconsistent with count field.\n", line); break; - } - } + } + } checksum = (~checksum) & 0xff; - if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) { + if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) + { printf ("line %d: S record checksum missing or invalid.\n", line); done = 0; break; - } + } fscanf (fp, "%*[\r\n]"); /* skip any form of line ending */ break; - case 9: /* 16-bit start address */ + case 9: checksum = (~checksum) & 0xff; if ( (fscanf (fp, "%2x", &data) != 1) || (data != checksum) ) printf ("line %d: S record checksum missing or invalid.\n", line); @@ -1274,7 +1303,8 @@ int load_s19(FILE *fp) void monitor_call (unsigned int flags) { #ifdef CALL_STACK - if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1]) { + if (current_function_call <= &fctab[MAX_FUNCTION_CALLS-1]) + { current_function_call++; current_function_call->entry_point = get_pc (); current_function_call->flags = flags; @@ -1282,7 +1312,8 @@ void monitor_call (unsigned int flags) #endif #if 0 const char *id = sym_lookup (&program_symtab, to_absolute (get_pc ())); - if (id) { + if (id) + { // printf ("In %s now\n", id); } #endif @@ -1291,13 +1322,15 @@ void monitor_call (unsigned int flags) void monitor_return (void) { #ifdef CALL_STACK - if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1]) { + if (current_function_call > &fctab[MAX_FUNCTION_CALLS-1]) + { current_function_call--; return; } while ((current_function_call->flags & FC_TAIL_CALL) && - (current_function_call > fctab)) { + (current_function_call > fctab)) + { current_function_call--; } @@ -1350,8 +1383,7 @@ void monitor_init (void) { extern int debug_enabled; - /* PC has already been initialised to program entry point */ - fctab[0].entry_point = get_pc(); + fctab[0].entry_point = read16 (0xfffe); memset (&fctab[0].entry_regs, 0, sizeof (struct cpu_regs)); current_function_call = &fctab[0]; diff --git a/monitor.h b/monitor.h index cca71b0..a93091c 100644 --- a/monitor.h +++ b/monitor.h @@ -72,12 +72,9 @@ struct function_call { void add_named_symbol (const char *id, target_addr_t value, const char *filename); struct x_symbol * find_symbol (target_addr_t value); - void monitor_branch (void); void monitor_call (unsigned int flags); void monitor_return (void); -void monitor_backtrace (void); - const char * monitor_addr_name (target_addr_t addr); const char * absolute_addr_name (unsigned long addr); diff --git a/timer.c b/timer.c index 960f898..db6a09a 100644 --- a/timer.c +++ b/timer.c @@ -20,7 +20,7 @@ #include #include -#include "6809.h" +#include "machine.h" /* A hardware timer counts CPU cycles and can generate interrupts periodically. */ struct hwtimer From 1d8d78d66d2e3b6dda35b7cbdb687cd6420f1df4 Mon Sep 17 00:00:00 2001 From: nealcrook Date: Fri, 21 Oct 2016 23:09:37 +0100 Subject: [PATCH 50/71] Revert "force PC to be truncated to 16-bits to avoid it goinf to large negative value" This reverts commit f39131a51df5f8ec4afb2b4985fcfdebcee72201. --- 6809.c | 68 +++++++++++++++++++++++----------------------------------- 6809.h | 40 +++++++++++++++++----------------- 2 files changed, 47 insertions(+), 61 deletions(-) diff --git a/6809.c b/6809.c index 02e79a2..8f70380 100644 --- a/6809.c +++ b/6809.c @@ -172,10 +172,7 @@ static inline void change_pc (unsigned newPC) fprintf (stderr, "-> %s\n", monitor_addr_name (newPC)); } #endif - PC = newPC & 0xffff; /* [NAC HACK 2016Oct21] stop PC from going out of range. Crude. - why have I not seen this problem before? Did I introduce this - bug as a side-effect of another change? - */ + PC = newPC; } static inline unsigned imm_byte (void) @@ -392,47 +389,47 @@ static void extended (void) /* external register functions */ -U8 get_a (void) +unsigned get_a (void) { return A; } -U8 get_b (void) +unsigned get_b (void) { return B; } -U8 get_dp (void) +unsigned get_dp (void) { return DP >> 8; } -U16 get_x (void) +unsigned get_x (void) { return X; } -U16 get_y (void) +unsigned get_y (void) { return Y; } -U16 get_s (void) +unsigned get_s (void) { return S; } -U16 get_u (void) +unsigned get_u (void) { return U; } -U16 get_pc (void) +unsigned get_pc (void) { return PC & 0xffff; } -U16 get_d (void) +unsigned get_d (void) { return (A << 8) | B; } @@ -479,49 +476,49 @@ unsigned get_md (void) } #endif -void set_a (U8 val) +void set_a (unsigned val) { A = val & 0xff; } -void set_b (U8 val) +void set_b (unsigned val) { B = val & 0xff; } -void set_dp (U8 val) +void set_dp (unsigned val) { DP = (val & 0xff) << 8; } -void set_x (U16 val) +void set_x (unsigned val) { X = val & 0xffff; } -void set_y (U16 val) +void set_y (unsigned val) { Y = val & 0xffff; } -void set_s (U16 val) +void set_s (unsigned val) { S = val & 0xffff; check_stack (); } -void set_u (U16 val) +void set_u (unsigned val) { U = val & 0xffff; } -void set_pc (U16 val) +void set_pc (unsigned val) { PC = val & 0xffff; check_pc (); } -void set_d (U16 val) +void set_d (unsigned val) { A = (val >> 8) & 0xff; B = val & 0xff; @@ -567,7 +564,7 @@ void set_md (unsigned val) /* handle condition code register */ -U8 get_cc (void) +unsigned get_cc (void) { unsigned res = EFI & (E_FLAG | F_FLAG | I_FLAG); @@ -585,7 +582,7 @@ U8 get_cc (void) return res; } -void set_cc (U8 arg) +void set_cc (unsigned arg) { EFI = arg & (E_FLAG | F_FLAG | I_FLAG); H = (arg & H_FLAG ? 0x10 : 0); @@ -1883,11 +1880,11 @@ int cpu_execute (int cycles) case 0x8b: /* ADDW */ break; #endif - case 0x8c: /* CMPY imm */ + case 0x8c: cpu_clk -= 5; cmp16 (Y, imm_word ()); break; - case 0x8e: /* LDY imm */ + case 0x8e: cpu_clk -= 4; Y = ld16 (imm_word ()); break; @@ -3044,24 +3041,13 @@ void print_regs (void) if (get_cc() & F_FLAG) flags[6] = 'F'; if (get_cc() & E_FLAG) flags[7] = 'E'; - /* printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", - get_x(), 0xffff & read16(get_x()), get_y(), 0xffff & read16(get_y()) ); - printf ("PC: 0x%04X [PC]: 0x%04X\n", - get_pc(), read16(get_pc()) ); - printf (" U: 0x%04X [U]: 0x%04X S: 0x%04X [S]: 0x%04X ", - get_u(), 0xffff & read16(get_u()), get_s(), 0xffff & read16(get_s()) ); - printf ("DP: 0x%02X\n", get_dp() ); - printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", - get_a(), get_b(), 0xffff & read16(get_d()), flags ); - */ - printf (" X: 0x%04X [X]: 0x%04X Y: 0x%04X [Y]: 0x%04X ", - get_x(), 0xffff & 0, get_y(), 0xffff & 0 ); + get_x(), read16(get_x()), get_y(), read16(get_y()) ); printf ("PC: 0x%04X [PC]: 0x%04X\n", - get_pc(), 0 ); + get_pc(), read16(get_pc()) ); printf (" U: 0x%04X [U]: 0x%04X S: 0x%04X [S]: 0x%04X ", - get_u(), 0xffff & 0, get_s(), 0xffff & 0 ); + get_u(), read16(get_u()), get_s(), read16(get_s()) ); printf ("DP: 0x%02X\n", get_dp() ); printf (" A: 0x%02X B: 0x%02X [D]: 0x%04X CC: %s\n", - get_a(), get_b(), 0xffff & 0, flags ); + get_a(), get_b(), read16(get_d()), flags ); } diff --git a/6809.h b/6809.h index 3e5ccb8..d5fc634 100644 --- a/6809.h +++ b/6809.h @@ -91,27 +91,27 @@ extern int cpu_quit; extern int cpu_execute (int); extern void cpu_reset (void); -extern U8 get_a (void); -extern U8 get_b (void); -extern U8 get_cc (void); -extern U8 get_dp (void); -extern U16 get_x (void); -extern U16 get_y (void); -extern U16 get_s (void); -extern U16 get_u (void); -extern U16 get_pc (void); -extern U16 get_d (void); +extern unsigned get_a (void); +extern unsigned get_b (void); +extern unsigned get_cc (void); +extern unsigned get_dp (void); +extern unsigned get_x (void); +extern unsigned get_y (void); +extern unsigned get_s (void); +extern unsigned get_u (void); +extern unsigned get_pc (void); +extern unsigned get_d (void); extern unsigned get_flags (void); -extern void set_a (U8); -extern void set_b (U8); -extern void set_cc (U8); -extern void set_dp (U8); -extern void set_x (U16); -extern void set_y (U16); -extern void set_s (U16); -extern void set_u (U16); -extern void set_pc (U16); -extern void set_d (U16); +extern void set_a (unsigned); +extern void set_b (unsigned); +extern void set_cc (unsigned); +extern void set_dp (unsigned); +extern void set_x (unsigned); +extern void set_y (unsigned); +extern void set_s (unsigned); +extern void set_u (unsigned); +extern void set_pc (unsigned); +extern void set_d (unsigned); /* fileio.c */ From 7d30a22b3437ca1e086d0ad38536f215fa433e48 Mon Sep 17 00:00:00 2001 From: nealcrook Date: Fri, 21 Oct 2016 23:14:38 +0100 Subject: [PATCH 51/71] Force PC to be truncated to 16-bit value to fix bug that popped up with long branch that made PC go to ffffc156 instead of c156. Don't know why this didn't come to light long ago. --- 6809.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/6809.c b/6809.c index 8f70380..9112136 100644 --- a/6809.c +++ b/6809.c @@ -172,7 +172,10 @@ static inline void change_pc (unsigned newPC) fprintf (stderr, "-> %s\n", monitor_addr_name (newPC)); } #endif - PC = newPC; + PC = newPC & 0xffff; /* [NAC HACK 2016Oct21] stop PC from going out of range. Crude. + why have I not seen this problem before? Did I introduce this + bug as a side-effect of another change? + */ } static inline unsigned imm_byte (void) From 748a1d1b56129b4a392726c10c6e608c779178ba Mon Sep 17 00:00:00 2001 From: nils-eilers Date: Tue, 13 Dec 2016 20:17:42 +0100 Subject: [PATCH 52/71] Add missing prototypes --- 6809.c | 1 + 6809.h | 8 ++++++++ command.c | 8 +++++--- command.h | 17 ++++++++++++++++ eon.c | 5 +++++ imux.c | 10 ++-------- imux.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ ioexpand.c | 12 +++--------- ioexpand.h | 50 +++++++++++++++++++++++++++++++++++++++++++++++ machine.c | 2 ++ machine.h | 26 +++++++++++++++++++++++++ main.c | 5 +++++ miscsbc.c | 5 +++-- mmu.c | 15 +------------- mmu.h | 29 +++++++++++++++++++++++++++ monitor.c | 5 +++-- monitor.h | 12 ++++++++++-- serial.c | 17 +--------------- serial.h | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ symtab.h | 29 +++++++++++++++++++++++++++ timer.c | 20 +++---------------- timer.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++ wpc.c | 2 ++ wpclib.c | 1 + 24 files changed, 370 insertions(+), 73 deletions(-) create mode 100644 command.h create mode 100644 imux.h create mode 100644 ioexpand.h create mode 100644 mmu.h create mode 100644 serial.h create mode 100644 symtab.h create mode 100644 timer.h diff --git a/6809.c b/6809.c index 9112136..2a6dd6a 100644 --- a/6809.c +++ b/6809.c @@ -21,6 +21,7 @@ #include "6809.h" #include "monitor.h" +#include "command.h" #include unsigned X, Y, S, U, PC; diff --git a/6809.h b/6809.h index d5fc634..bea5bec 100644 --- a/6809.h +++ b/6809.h @@ -237,5 +237,13 @@ typedef struct #define MAX_THREADS 64 void command_irq_hook (unsigned long cycles); +unsigned long get_cycles (void); +void request_irq (unsigned int source); +void release_irq (unsigned int source); +void request_firq (unsigned int source); +void release_firq (unsigned int source); +void sim_error (const char *format, ...); +void sim_exit (uint8_t exit_code); +void print_regs (void); #endif /* M6809_H */ diff --git a/command.c b/command.c index fa2da11..6ae9370 100644 --- a/command.c +++ b/command.c @@ -5,6 +5,7 @@ #include "machine.h" #include #include +#include #ifdef HAVE_TERMIOS_H # include #else @@ -80,6 +81,7 @@ unsigned long irq_cycles = 0; unsigned long eval (char *expr, char *eflag); unsigned long eval_mem (char *expr, eval_mode_t mode, char *eflag); +static int print_insn_long (absolute_address_t addr); extern int auto_break_insn_count; FILE *command_input; @@ -1345,7 +1347,7 @@ command_handler_t command_lookup (const char *cmd) return NULL; } -int print_insn_long (absolute_address_t addr) +static int print_insn_long (absolute_address_t addr) { char buf[64]; int i; @@ -1466,7 +1468,7 @@ void keybuffering (int flag) /* Non-blocking check for input character. If * true, retreive character using kbchar() */ -int kbhit() +int kbhit(void) { struct timeval tv = { 0L, 0L }; fd_set fds; @@ -1475,7 +1477,7 @@ int kbhit() return select(1, &fds, NULL, NULL, &tv); } -int kbchar() +int kbchar(void) { int r; unsigned char c; diff --git a/command.h b/command.h new file mode 100644 index 0000000..cac32ea --- /dev/null +++ b/command.h @@ -0,0 +1,17 @@ +#ifndef COMMAND_H +#define COMMAND_H + +void keybuffering (int flag); +void command_periodic (void); +void command_exit_irq_hook (unsigned long cycles); +void command_insn_hook (void); +void command_init (void); +void keybuffering_defaults (void); +void print_current_insn (void); +int command_loop (void); +void command_read_hook (absolute_address_t addr); +void command_write_hook (absolute_address_t addr, U8 val); +int kbhit(void); +int kbchar(void); + +#endif diff --git a/eon.c b/eon.c index bb084c2..5ea5a38 100644 --- a/eon.c +++ b/eon.c @@ -1,6 +1,11 @@ #include #include "machine.h" #include "eon.h" +#include "mmu.h" +#include "ioexpand.h" +#include "serial.h" +#include "imux.h" +#include "timer.h" /** diff --git a/imux.c b/imux.c index 371b2f2..90c5bdb 100644 --- a/imux.c +++ b/imux.c @@ -23,14 +23,8 @@ #include #include "machine.h" #include "eon.h" - -struct imux -{ - unsigned int in_use; /* Bits for each int that are used */ - unsigned int enabled; /* Bits for each int that is enabled */ - unsigned int pending; /* Bits for each int that are active */ - unsigned int src; /* Source line back to CPU */ -}; +#include "6809.h" +#include "imux.h" /* diff --git a/imux.h b/imux.h new file mode 100644 index 0000000..615f98e --- /dev/null +++ b/imux.h @@ -0,0 +1,57 @@ +/* + * Copyright 2009 by Brian Dominy + * + * This file is part of GCC6809. + * + * GCC6809 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. + * + * GCC6809 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 GCC6809; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +/* The interrupt multiplexer */ + +#ifndef IMUX_H +#define IMUX_H + +struct imux +{ + unsigned int in_use; /* Bits for each int that are used */ + unsigned int enabled; /* Bits for each int that is enabled */ + unsigned int pending; /* Bits for each int that are active */ + unsigned int src; /* Source line back to CPU */ +}; + + +/* + * Refresh the state of the interrupt line back to the CPU. + * src == 1 refers to IRQ, src == 2 for FIRQ. + */ +void imux_refresh (struct imux *mux); +void imux_reset (struct hw_device *dev); +U8 imux_read (struct hw_device *dev, unsigned long addr); +void imux_write (struct hw_device *dev, unsigned long addr, U8 val); + +/* + * Register an interrupt line with the multiplexer. + * This just tracks which ones are in use. + */ +void imux_register (struct hw_device *dev, unsigned int sig); + +/* + * Assert an edge-triggered interrupt line. + */ +void imux_assert (struct hw_device *dev, unsigned int sig); + +struct hw_device *imux_create (unsigned int cpu_line); + +#endif diff --git a/ioexpand.c b/ioexpand.c index 77da240..27fb436 100644 --- a/ioexpand.c +++ b/ioexpand.c @@ -21,6 +21,9 @@ #include #include #include "machine.h" +#include "ioexpand.h" +#include "6809.h" + /* An I/O expander subdivides a single, 128-byte region into 16, 8-byte slots each of which can hold a device. It is needed to work around the inability of the system @@ -28,15 +31,6 @@ bus to handle attaching devices less than 128 bytes in size. When mapping a slot, an offset can be applied to the underlying device. An example application is to make the I/O expander occupy fewer than 128 bytes by mapping one or more slots to a large underlying ROM. */ -#define NR_IOEXPAND 16 -#define IO_WINDOW 8 - -struct ioexpand -{ - struct hw_device *ios[NR_IOEXPAND]; - unsigned long offset[NR_IOEXPAND]; -}; - void ioexpand_attach (struct hw_device *expander_dev, int slot, unsigned long offset, struct hw_device *io_dev) { struct ioexpand *iom = (struct ioexpand *)expander_dev->priv; diff --git a/ioexpand.h b/ioexpand.h new file mode 100644 index 0000000..3ad0124 --- /dev/null +++ b/ioexpand.h @@ -0,0 +1,50 @@ +/* + * Copyright 2009 by Brian Dominy + * + * This file is part of GCC6809. + * + * GCC6809 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. + * + * GCC6809 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 GCC6809; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef IOEXPAND_H +#define IOEXPAND_H + +/* An I/O expander subdivides a single, 128-byte region into 16, 8-byte slots + each of which can hold a device. It is needed to work around the inability + of the system bus to handle attaching devices less than 128 bytes in size. + + When mapping a slot, an offset can be applied to the underlying device. An + example application is to make the I/O expander occupy fewer than 128 bytes + by mapping one or more slots to a large underlying ROM. + */ + + +#define NR_IOEXPAND 16 +#define IO_WINDOW 8 + +struct ioexpand +{ + struct hw_device *ios[NR_IOEXPAND]; + unsigned long offset[NR_IOEXPAND]; +}; + +struct hw_device *ioexpand_create (void); +void ioexpand_attach (struct hw_device *expander_dev, int slot, unsigned long offset, struct hw_device *io_dev); +void ioexpand_reset (struct hw_device *dev); +U8 ioexpand_read (struct hw_device *dev, unsigned long addr); +void ioexpand_write (struct hw_device *dev, unsigned long addr, U8 val); +struct hw_device *ioexpand_create (void); + +#endif diff --git a/machine.c b/machine.c index 0110886..e284807 100644 --- a/machine.c +++ b/machine.c @@ -22,6 +22,8 @@ #include #include #include "machine.h" +#include "command.h" +#include "monitor.h" #include "6809.h" #include "eon.h" diff --git a/machine.h b/machine.h index 05437d9..037148d 100644 --- a/machine.h +++ b/machine.h @@ -157,5 +157,31 @@ struct hw_device *console_create (void); struct hw_device *disk_create (const char *backing_file, struct hw_device *ram_dev); void fault (unsigned int addr, unsigned char type); +U8 ram_read (struct hw_device *dev, unsigned long addr); +U8 cpu_read8 (unsigned int addr); +U16 cpu_read16 (unsigned int addr); +void cpu_write8 (unsigned int addr, U8 val); +U8 abs_read8 (absolute_address_t addr); +void abs_write8 (absolute_address_t addr, U8 val); +void cpu_is_running (void); +void machine_init (const char *machine_name, const char *boot_rom_file); +absolute_address_t to_absolute (unsigned long cpuaddr); +void dump_machine(void); +void describe_machine (void); +void machine_update (void); +void print_device_name (unsigned int devno); +void device_define (struct hw_device *dev, + unsigned long offset, + unsigned int addr, + unsigned int len, + unsigned int flags); +void bus_map (unsigned int addr, + unsigned int devid, + unsigned long offset, + unsigned int len, + unsigned int flags); +void bus_unmap (unsigned int addr, unsigned int len); +struct hw_device *mmu_create (void); +struct hw_device *null_create (void); #endif /* _M6809_MACHINE_H */ diff --git a/main.c b/main.c index 3785d69..a417714 100644 --- a/main.c +++ b/main.c @@ -21,7 +21,12 @@ #include +#include #include "6809.h" +#include "command.h" +#include "symtab.h" +#include "machine.h" +#include "monitor.h" /* The total number of cycles that have executed */ unsigned long total = 0; diff --git a/miscsbc.c b/miscsbc.c index 6433f32..aa3cc03 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -1,8 +1,9 @@ #include -#include "machine.h" #include -// for symtab stuff? +#include "machine.h" #include "6809.h" +#include "ioexpand.h" +#include "command.h" // for smii console int smii_i_avail = 1; diff --git a/mmu.c b/mmu.c index 6d0054c..dddf9dd 100644 --- a/mmu.c +++ b/mmu.c @@ -1,19 +1,6 @@ #include #include "machine.h" - -#define SMR_PAGESIZE 4096 - -#define SMR_SLOTS 16 - -/* Small MMU register map */ -#define SMR_SLOT 0 /* Which slot is described by registers 8-9 */ -#define SMR_BASEL 1 /* The base page for lower 8 slots */ -#define SMR_BASEH 2 /* The base page for upper 8 slots */ -#define SMR_FAULTA 3 /* The faulting address */ -#define SMR_FAULTT 5 /* The fault type */ -#define SM_GLOBAL_REGS 6 -#define SMR_PAGE 6 /* Which 4KB page is mapped to the current slot */ -#define SMR_FLAGS 7 /* What are the page flags for this slot */ +#include "mmu.h" /* The 'small' MMU is an I/O device that allows remapping a window of a single device into a fixed region of the CPU. */ diff --git a/mmu.h b/mmu.h new file mode 100644 index 0000000..742a8b6 --- /dev/null +++ b/mmu.h @@ -0,0 +1,29 @@ +#ifndef MMU_H +#define MMU_H + +#define SMR_PAGESIZE 4096 + +#define SMR_SLOTS 16 + +/* Small MMU register map */ +#define SMR_SLOT 0 /* Which slot is described by registers 8-9 */ +#define SMR_BASEL 1 /* The base page for lower 8 slots */ +#define SMR_BASEH 2 /* The base page for upper 8 slots */ +#define SMR_FAULTA 3 /* The faulting address */ +#define SMR_FAULTT 5 /* The fault type */ +#define SM_GLOBAL_REGS 6 +#define SMR_PAGE 6 /* Which 4KB page is mapped to the current slot */ +#define SMR_FLAGS 7 /* What are the page flags for this slot */ + +/* The 'small' MMU is an I/O device that allows remapping a window of +a single device into a fixed region of the CPU. */ +struct small_mmu; +void small_mmu_update_slot (struct small_mmu *mmu, unsigned int slot); +void small_mmu_update_current (struct small_mmu *mmu); +void small_mmu_update_all (struct small_mmu *mmu); +U8 small_mmu_read (struct hw_device *dev, unsigned long addr); +void small_mmu_write (struct hw_device *dev, unsigned long addr, U8 val); +void small_mmu_reset (struct hw_device *dev); +struct hw_device* small_mmu_create (struct hw_device *realdev); + +#endif diff --git a/monitor.c b/monitor.c index 1d94ef3..b8cef8c 100644 --- a/monitor.c +++ b/monitor.c @@ -19,10 +19,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "6809.h" -#include "monitor.h" #include #include +#include "6809.h" +#include "monitor.h" +#include "command.h" /* The function call stack */ struct function_call fctab[MAX_FUNCTION_CALLS]; diff --git a/monitor.h b/monitor.h index a93091c..c965fbd 100644 --- a/monitor.h +++ b/monitor.h @@ -1,4 +1,5 @@ - +#ifndef MONITOR_H +#define MONITOR_H #define S_NAMED 0x1 #define S_OFFSET 0x2 @@ -16,6 +17,7 @@ #define PROMPT_CYCLES 0x2 #define PROMPT_INSN 0x4 +#include "6809.h" struct cpu_regs { unsigned X, Y, S, U, PC; @@ -77,6 +79,12 @@ void monitor_call (unsigned int flags); void monitor_return (void); const char * monitor_addr_name (target_addr_t addr); const char * absolute_addr_name (unsigned long addr); +void monitor_backtrace (void); +const char* monitor_addr_name (target_addr_t target_addr); +int load_s19(FILE *fp); +int load_hex (FILE *fp); +int load_map_file (const char *name); +int sizeof_file(FILE * file); - +#endif diff --git a/serial.c b/serial.c index 5773a42..ace1f46 100644 --- a/serial.c +++ b/serial.c @@ -27,25 +27,10 @@ #include #include #include "machine.h" +#include "serial.h" /* Emulate a serial port. Basically this driver can be used for any byte-at-a-time input/output interface. */ -struct serial_port -{ - unsigned int ctrl; - unsigned int status; - int fin; - int fout; -}; - -/* The I/O registers exposed by this driver */ -#define SER_DATA 0 /* Data input/output */ -#define SER_CTL_STATUS 1 /* Control (write) and status (read) */ - #define SER_CTL_ASYNC 0x1 /* Enable async mode (more realistic) */ - #define SER_CTL_RESET 0x2 /* Reset device */ - - #define SER_STAT_READOK 0x1 - #define SER_STAT_WRITEOK 0x2 void serial_update (struct serial_port *port) { diff --git a/serial.h b/serial.h new file mode 100644 index 0000000..a3cc8f4 --- /dev/null +++ b/serial.h @@ -0,0 +1,51 @@ +/* + * Copyright 2009 by Brian Dominy + * + * This file is part of GCC6809. + * + * GCC6809 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. + * + * GCC6809 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 GCC6809; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SERIAL_H +#define SERIAL_H + +/* Emulate a serial port. Basically this driver can be used for any byte-at-a-time +input/output interface. */ +struct serial_port +{ + unsigned int ctrl; + unsigned int status; + int fin; + int fout; +}; + +/* The I/O registers exposed by this driver */ +#define SER_DATA 0 /* Data input/output */ +#define SER_CTL_STATUS 1 /* Control (write) and status (read) */ + #define SER_CTL_ASYNC 0x1 /* Enable async mode (more realistic) */ + #define SER_CTL_RESET 0x2 /* Reset device */ + + #define SER_STAT_READOK 0x1 + #define SER_STAT_WRITEOK 0x2 + +void serial_update (struct serial_port *port); +U8 serial_read (struct hw_device *dev, unsigned long addr); +void serial_write (struct hw_device *dev, unsigned long addr, U8 val); +void serial_reset (struct hw_device *dev); +extern U8 null_read (struct hw_device *dev, unsigned long addr); +struct hw_device* serial_create (void); +struct hw_device* hostfile_create (const char *filename, int flags); + +#endif diff --git a/symtab.h b/symtab.h new file mode 100644 index 0000000..a1aea4d --- /dev/null +++ b/symtab.h @@ -0,0 +1,29 @@ +/* + * Copyright 2008 by Brian Dominy + * + * This file is part of the Portable 6809 Simulator. + * + * The Simulator 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. + * + * The Simulator 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 software; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef SYMTAB_H +#define SYMTAB_H + +#include "6809.h" + +void sym_init (void); +void symtab_print (struct symtab *symtab); + +#endif diff --git a/timer.c b/timer.c index db6a09a..b60511c 100644 --- a/timer.c +++ b/timer.c @@ -21,25 +21,11 @@ #include #include #include "machine.h" +#include "6809.h" +#include "imux.h" +#include "timer.h" /* A hardware timer counts CPU cycles and can generate interrupts periodically. */ -struct hwtimer -{ - int count; /* The current value of the timer */ - unsigned int reload; /* Value to reload into the timer when it reaches zero */ - unsigned int resolution; /* Resolution of CPU registers (cycles/tick) */ - unsigned int flags; - unsigned long prev_cycles; - struct hw_device *int_dev; /* Which interrupt mux we use */ - unsigned int int_line; /* Which interrupt to signal */ -}; - -/* The I/O registers exposed by this driver */ -#define HWT_COUNT 0 /* The 8-bit timer counter */ -#define HWT_RELOAD 1 /* The 8-bit reload counter */ -#define HWT_FLAGS 2 /* Misc. flags */ - #define HWTF_INT 0x80 /* Generate interrupt at zero */ - /* * Called by the system to indicate that some number of CPU cycles have passed. diff --git a/timer.h b/timer.h new file mode 100644 index 0000000..8dd8dfd --- /dev/null +++ b/timer.h @@ -0,0 +1,56 @@ +/* + * Copyright 2009 by Brian Dominy + * + * This file is part of GCC6809. + * + * GCC6809 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. + * + * GCC6809 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 GCC6809; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + + +#ifndef TIMER_H +#define TIMER_H + +/* A hardware timer counts CPU cycles and can generate interrupts periodically. */ +struct hwtimer +{ + int count; /* The current value of the timer */ + unsigned int reload; /* Value to reload into the timer when it reaches zero */ + unsigned int resolution; /* Resolution of CPU registers (cycles/tick) */ + unsigned int flags; + unsigned long prev_cycles; + struct hw_device *int_dev; /* Which interrupt mux we use */ + unsigned int int_line; /* Which interrupt to signal */ +}; + +/* The I/O registers exposed by this driver */ +#define HWT_COUNT 0 /* The 8-bit timer counter */ +#define HWT_RELOAD 1 /* The 8-bit reload counter */ +#define HWT_FLAGS 2 /* Misc. flags */ + #define HWTF_INT 0x80 /* Generate interrupt at zero */ + + +/* + * Called by the system to indicate that some number of CPU cycles have passed. + */ +void hwtimer_decrement (struct hwtimer *timer, unsigned int cycles); +void hwtimer_update (struct hw_device *dev); +U8 hwtimer_read (struct hw_device *dev, unsigned long addr); +void hwtimer_write (struct hw_device *dev, unsigned long addr, U8 val); +void hwtimer_reset (struct hw_device *dev); +void oscillator_reset (struct hw_device *dev); +struct hw_device *hwtimer_create (struct hw_device *int_dev, unsigned int int_line); +struct hw_device *oscillator_create(struct hw_device *int_dev, unsigned int int_line); + +#endif diff --git a/wpc.c b/wpc.c index e6f94a8..0083634 100644 --- a/wpc.c +++ b/wpc.c @@ -24,11 +24,13 @@ #else #error #endif +#include #include #include #include #include #include "wpclib.h" +#include "machine.h" #define WPC_RAM_BASE 0x0000 #define WPC_RAM_SIZE 0x2000 diff --git a/wpclib.c b/wpclib.c index 526c65e..c5b8399 100644 --- a/wpclib.c +++ b/wpclib.c @@ -7,6 +7,7 @@ #include #include #include +#include #include "wpclib.h" #define UDP_PORT 7400 From 4bda2ef9f089453c87420d2659ff537964d320da Mon Sep 17 00:00:00 2001 From: nils-eilers Date: Wed, 14 Dec 2016 17:30:23 +0100 Subject: [PATCH 53/71] Remove dead code --- 6809.c | 4 ---- wpclib.c | 6 ------ wpclib.h | 1 - 3 files changed, 11 deletions(-) diff --git a/6809.c b/6809.c index 2a6dd6a..0d8f962 100644 --- a/6809.c +++ b/6809.c @@ -556,10 +556,6 @@ void set_v (unsigned val) V = val & 0xff; } -void set_zero (unsigned val) -{ -} - void set_md (unsigned val) { MD = val & 0xff; diff --git a/wpclib.c b/wpclib.c index c5b8399..a2e1fbd 100644 --- a/wpclib.c +++ b/wpclib.c @@ -99,12 +99,6 @@ int wpc_msg_init (int code, struct wpc_message *msg) return 0; } -int wpc_msg_insert (struct wpc_message *msg, const void *p, int len) -{ - memcpy (msg->u.data + msg->len, p, len); - msg->len += len; -} - int wpc_msg_send (int s, int dstport, struct wpc_message *msg) { int rc = udp_socket_send (s, dstport, msg, msg->len + sizeof (struct wpc_message) - 1000); diff --git a/wpclib.h b/wpclib.h index 84c9316..6101f4e 100644 --- a/wpclib.h +++ b/wpclib.h @@ -33,7 +33,6 @@ struct wpc_message }; int wpc_msg_init (int code, struct wpc_message *msg); -int wpc_msg_insert (struct wpc_message *msg, const void *p, int len); int wpc_msg_send (int s, int dstport, struct wpc_message *msg); #define CODE_DMD_PAGE 0 From e78408f84957a96e962edae0b29eb17598dbf37f Mon Sep 17 00:00:00 2001 From: nils-eilers Date: Wed, 14 Dec 2016 17:31:44 +0100 Subject: [PATCH 54/71] Fix some warnings --- command.c | 69 +++++++++++++++++++++++++++++++++++++++---------------- disk.c | 3 +-- machine.c | 17 +++++++++----- main.c | 11 +++------ miscsbc.c | 3 +-- mmu.c | 1 - monitor.c | 16 ++++++------- serial.c | 10 ++++---- timer.c | 5 +++- wpc.c | 12 ++++++---- wpclib.c | 5 ++-- wpclib.h | 4 ++-- 12 files changed, 95 insertions(+), 61 deletions(-) diff --git a/command.c b/command.c index 6ae9370..c6565c5 100644 --- a/command.c +++ b/command.c @@ -3,6 +3,7 @@ #include "6809.h" #include "monitor.h" #include "machine.h" +#include "symtab.h" #include #include #include @@ -11,6 +12,11 @@ #else #error #endif +#ifdef HAVE_READLINE +# include +# include +# include +#endif struct termios old_tio, new_tio; @@ -96,7 +102,7 @@ void print_addr (absolute_address_t addr) print_device_name (addr >> 28); putchar (':'); - printf ("0x%04X", addr & 0xFFFFFF); + printf ("0x%04lX", addr & 0xFFFFFF); name = sym_lookup (&program_symtab, addr); if (name) @@ -200,13 +206,10 @@ void eval_assign (char *expr, unsigned long val, char *eflag) unsigned long target_read (absolute_address_t addr, unsigned int size) { - switch (size) - { - case 1: - return abs_read8 (addr); - case 2: - return abs_read16 (addr); - } + if (size == 1) + return abs_read8(addr); + else + return abs_read16(addr); } /* Extract any valid format flags - ignore anything else @@ -512,9 +515,10 @@ display_t* display_alloc (void) if (!ds->used) { ds->used = 1; - return ds; /* TODO bug: missing return otherwise */ + return ds; } } + return NULL; } void display_free (display_t *ds) @@ -1357,7 +1361,7 @@ static int print_insn_long (absolute_address_t addr) print_device_name(addr >> 28); putchar(':'); - printf("0x%04X ", addr & 0xFFFFFF); + printf("0x%04lX ", addr & 0xFFFFFF); for (i = 0; i < size; i++) printf("%02X", abs_read8(addr + i)); @@ -1641,34 +1645,59 @@ void command_periodic (void) } void pc_virtual (unsigned long *val, int writep) { - writep ? set_pc (*val) : (*val = get_pc ()); + if (writep) set_pc (*val); + else *val = get_pc (); } void x_virtual (unsigned long *val, int writep) { - writep ? set_x (*val) : (*val = get_x ()); + if (writep) set_x (*val); + else *val = get_x (); } void y_virtual (unsigned long *val, int writep) { - writep ? set_y (*val) : (*val = get_y ()); + if (writep) + set_y (*val); + else *val = get_y (); } void u_virtual (unsigned long *val, int writep) { - writep ? set_u (*val) : (*val = get_u ()); + if (writep) + set_u (*val); + else + *val = get_u (); } void s_virtual (unsigned long *val, int writep) { - writep ? set_s (*val) : (*val = get_s ()); + if (writep) + set_s (*val); + else + *val = get_s (); } void d_virtual (unsigned long *val, int writep) { - writep ? set_d (*val) : (*val = get_d ()); + if (writep) + set_d (*val); + else + *val = get_d (); } void a_virtual (unsigned long *val, int writep) { - writep ? set_a (*val) : (*val = get_a ()); + if (writep) + set_a (*val); + else + *val = get_a (); } void b_virtual (unsigned long *val, int writep) { - writep ? set_b (*val) : (*val = get_b ()); + if (writep) + set_b (*val); + else + *val = get_b (); } void dp_virtual (unsigned long *val, int writep) { - writep ? set_dp (*val) : (*val = get_dp ()); + if (writep) + set_dp (*val); + else + *val = get_dp (); } void cc_virtual (unsigned long *val, int writep) { - writep ? set_cc (*val) : (*val = get_cc ()); + if (writep) + set_cc (*val); + else + *val = get_cc (); } void irq_load_virtual (unsigned long *val, int writep) { if (!writep) diff --git a/disk.c b/disk.c index 3bc19e0..a597081 100644 --- a/disk.c +++ b/disk.c @@ -69,7 +69,6 @@ void disk_update (struct hw_device *dev) U8 disk_read (struct hw_device *dev, unsigned long addr) { - struct disk_priv *disk = (struct disk_priv *)dev->priv; return 0; } @@ -80,7 +79,7 @@ void disk_write (struct hw_device *dev, unsigned long addr, U8 val) switch (addr) { case DSK_ADDR: - disk->ram = (U8*) disk->ramdev->priv + val * SECTOR_SIZE; + disk->ram = (char*) disk->ramdev->priv + val * SECTOR_SIZE; break; case DSK_SECTOR: disk->offset = val; /* high byte */ diff --git a/machine.c b/machine.c index e284807..bf22c1f 100644 --- a/machine.c +++ b/machine.c @@ -85,7 +85,7 @@ struct hw_device *device_attach (struct hw_class *class_ptr, unsigned int size, /* Attach implies reset */ class_ptr->reset (dev); return dev; -}; +} /** * Map a portion of a device into the CPU's address space. @@ -181,7 +181,6 @@ static struct hw_device *find_device (unsigned int addr, unsigned char id) void print_device_name (unsigned int devno) { - struct hw_device *dev = device_table[devno]; printf ("%02X", devno); } @@ -331,7 +330,6 @@ absolute_address_t to_absolute (unsigned long cpuaddr) if (cpuaddr > 0xffff) return (absolute_address_t)cpuaddr; struct bus_map *map = find_map (cpuaddr); - struct hw_device *dev = find_device (cpuaddr, map->devid); unsigned long phy_addr = map->offset + cpuaddr % BUS_MAP_SIZE; return absolute_from_reladdr (map->devid, phy_addr); } @@ -354,8 +352,8 @@ void describe_machine (void) unsigned int devno; unsigned int mapno; unsigned int prev_devid = -1; - unsigned int prev_offset; - unsigned int prev_flags; + unsigned int prev_offset = 0; + unsigned int prev_flags = 0; unsigned int dot_dot = 0; /* machine */ @@ -384,7 +382,7 @@ void describe_machine (void) else { dot_dot = 0; - printf ("Map %3d: addr=%04X dev=%d offset=%04X size=%06X flags=%02X\n", + printf ("Map %3d: addr=%04X dev=%d offset=%04lX size=%06lX flags=%02X\n", mapno, mapno * BUS_MAP_SIZE, map->devid, map->offset, device_table[map->devid]->size, map->flags); } @@ -416,15 +414,22 @@ void fault (unsigned int addr, unsigned char type) void null_reset (struct hw_device *dev) { + (void) dev; // silence warning unused parameter } U8 null_read (struct hw_device *dev, unsigned long addr) { + (void) dev; // silence warning unused parameter + (void) addr; + return 0xFF; } void null_write (struct hw_device *dev, unsigned long addr, U8 val) { + (void) dev; // silence warning unused parameter + (void) addr; + (void) val; } struct hw_class null_class = diff --git a/main.c b/main.c index a417714..49a73c7 100644 --- a/main.c +++ b/main.c @@ -170,7 +170,7 @@ struct option const char *help; unsigned int can_negate : 1; unsigned int takes_arg : 1; - int *int_value; + int *int_value; int default_value; /* value to set if option is present */ const char **string_value; int (*handler) (const char *arg); @@ -293,7 +293,7 @@ process_option (struct option *opt, const char *arg) } -int +void process_plain_argument (const char *arg) { //printf ("plain argument '%s'\n", arg); @@ -302,7 +302,7 @@ process_plain_argument (const char *arg) } -int +void parse_args (int argc, char *argv[]) { int argn = 1; @@ -363,11 +363,6 @@ parse_args (int argc, char *argv[]) int main (int argc, char *argv[]) { - int off = 0; - int i, j, n; - int argn = 1; - unsigned int loops = 0; - gettimeofday (&time_started, NULL); exename = argv[0]; diff --git a/miscsbc.c b/miscsbc.c index aa3cc03..526c14c 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -508,7 +508,6 @@ void sdmapper_remap(int op, int val) U8 sdmapper_read (struct hw_device *dev, unsigned long addr) { - unsigned char ch; //printf("INFO In sdmapper_read with addr=0x%08x, mc_state=%d, mc_poll=%d\n", addr, mc_state, mc_poll); switch (addr) { case 0: // SDDATA @@ -588,8 +587,8 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) default: printf("INFO In sdmapper_read with addr=0x%08x\n", (unsigned char)addr); //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x42); - return 0x42; } + return 0x42; // return default value } // TODO expand RAM and implement mapper, protect and rom disable diff --git a/mmu.c b/mmu.c index dddf9dd..bf03582 100644 --- a/mmu.c +++ b/mmu.c @@ -68,7 +68,6 @@ void small_mmu_write (struct hw_device *dev, unsigned long addr, U8 val) void small_mmu_reset (struct hw_device *dev) { unsigned int page; - struct small_mmu *mmu = (struct small_mmu *)dev->priv; for (page = 0; page < SMR_SLOTS; page++) { diff --git a/monitor.c b/monitor.c index b8cef8c..ae709a3 100644 --- a/monitor.c +++ b/monitor.c @@ -895,6 +895,7 @@ int dasm (char *buf, absolute_address_t opc) absolute_address_t pc = opc; char R; int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */ + absolute_address_t tmp; op = fetch8(); @@ -1027,12 +1028,13 @@ int dasm (char *buf, absolute_address_t opc) break; case _rel_byte: - fetch1 = ((INT8) fetch8 ()); + fetch1 = ((INT8) fetch8 ()); sprintf (buf, "%s", absolute_addr_name (fetch1 + pc)); break; case _rel_word: - sprintf (buf, "%s", absolute_addr_name (fetch16() + pc)); + tmp = fetch16(); + sprintf (buf, "%s", absolute_addr_name (pc + tmp)); break; case _reg_post: @@ -1091,8 +1093,6 @@ int load_map_file (const char *name) char buf[256]; char *tok_ptr, *value_ptr, *id_ptr; target_addr_t value; - char *file_ptr; - struct symbol *sym = NULL; /* Try appending the suffix 'map' to the name of the program. */ sprintf (map_filename, "%s.map", name); @@ -1147,7 +1147,7 @@ int load_map_file (const char *name) */ int load_image (const char *name) { - int count, addr, type; + unsigned int count, addr, type; FILE *fp; fp = file_open(NULL, name, "r"); @@ -1176,7 +1176,7 @@ int load_image (const char *name) int load_hex (FILE *fp) { - int count, addr, type, data, checksum; + unsigned int count, addr, type, data, checksum; int done = 1; int line = 0; @@ -1240,7 +1240,7 @@ int load_hex (FILE *fp) int load_s19(FILE *fp) { - int count, addr, type, data, checksum; + unsigned int count, addr, type, data, checksum; int done = 1; int line = 0; @@ -1347,7 +1347,7 @@ const char* absolute_addr_name (absolute_address_t addr) bufptr = buf; - bufptr += sprintf (bufptr, "%02X:0x%04X", addr >> 28, addr & 0xFFFFFF); + bufptr += sprintf (bufptr, "%02lX:0x%04lX", addr >> 28, addr & 0xFFFFFF); name = sym_lookup (&program_symtab, addr); if (name) diff --git a/serial.c b/serial.c index ace1f46..d68614a 100644 --- a/serial.c +++ b/serial.c @@ -36,7 +36,6 @@ void serial_update (struct serial_port *port) { fd_set infds, outfds; struct timeval timeout; - int rc; FD_ZERO (&infds); FD_SET (port->fin, &infds); @@ -44,7 +43,7 @@ void serial_update (struct serial_port *port) FD_SET (port->fout, &outfds); timeout.tv_sec = 0; timeout.tv_usec = 0; - rc = select (2, &infds, &outfds, NULL, &timeout); + select (2, &infds, &outfds, NULL, &timeout); if (FD_ISSET (port->fin, &infds)) port->status |= SER_STAT_READOK; else @@ -72,8 +71,11 @@ U8 serial_read (struct hw_device *dev, unsigned long addr) return val; } case SER_CTL_STATUS: - return port->status; - } + return port->status; + default: + fprintf(stderr, "serial_read() from undefined addr\n"); + } + return 0x42; } void serial_write (struct hw_device *dev, unsigned long addr, U8 val) diff --git a/timer.c b/timer.c index b60511c..8011847 100644 --- a/timer.c +++ b/timer.c @@ -90,6 +90,9 @@ U8 hwtimer_read (struct hw_device *dev, unsigned long addr) return timer->reload / timer->resolution; case HWT_FLAGS: return timer->flags; + default: + fprintf(stderr, "Read hwtimer from undefined addr\n"); + return 0x42; } } @@ -106,7 +109,7 @@ void hwtimer_write (struct hw_device *dev, unsigned long addr, U8 val) break; case HWT_FLAGS: timer->flags = val; - break; + break; } } diff --git a/wpc.c b/wpc.c index 0083634..87d3616 100644 --- a/wpc.c +++ b/wpc.c @@ -193,7 +193,6 @@ static U8 wpc_get_console_state (void) static U8 wpc_console_read (void) { - int rc; U8 c = 0; if (!wpc_console_inited) @@ -202,7 +201,7 @@ static U8 wpc_console_read (void) return 0; } - rc = read (0, &c, 1); + read (0, &c, 1); return c; } @@ -271,6 +270,8 @@ unsigned int wpc_read_switch_column (int col) void wpc_write_lamp (int num, int flag) { + (void) num; // silence warning unused parameter + (void) flag; } @@ -334,7 +335,7 @@ void wpc_dmd_set_visible (U8 val) wpc_msg_init (CODE_DMD_PAGE, &msg); for (i=0; i < 3; i++) { - p = (U8*) wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512; + p = (char*) wpc->dmd_dev->priv + wpc->dmd_visibles[i] * 512; msg.u.dmdpage.phases[i].page = wpc->dmd_visibles[i]; memcpy (&msg.u.dmdpage.phases[i].data, p, 512); } @@ -588,7 +589,7 @@ void wpc_asic_write (struct hw_device *dev, unsigned long addr, U8 val) case WPC_SOL_FLASH1_OUTPUT: case WPC_SOL_LOWPOWER_OUTPUT: if (val != 0) - printf (">>> ASIC write %04X %02X\n", addr + WPC_ASIC_BASE, val); + printf (">>> ASIC write %04lX %02X\n", addr + WPC_ASIC_BASE, val); break; default: @@ -648,10 +649,13 @@ struct hw_device *wpc_asic_create (void) void wpc_fault (unsigned int addr, unsigned char type) { + (void) addr; // silence warning unused parameter + (void) type; } void wpc_dump_thread (unsigned int thread_id) { + (void) thread_id; // silence warning unused parameter } void io_sym_add (const char *name, unsigned long cpuaddr) diff --git a/wpclib.c b/wpclib.c index a2e1fbd..2ea60f1 100644 --- a/wpclib.c +++ b/wpclib.c @@ -59,7 +59,7 @@ int udp_socket_create (int port) return s; } -int udp_socket_send (int s, int dstport, const void *data, int len) +int udp_socket_send (int s, int dstport, const void *data, socklen_t len) { int rc; struct sockaddr_in to; @@ -76,11 +76,10 @@ int udp_socket_send (int s, int dstport, const void *data, int len) return rc; } -int udp_socket_receive (int s, int dstport, void *data, int len) +int udp_socket_receive (int s, int dstport, void *data, socklen_t len) { int rc; struct sockaddr_in from; - int fromlen; rc = recvfrom (s, data, len, 0, (struct sockaddr *)&from, &len); if ((rc < 0) && (errno != EAGAIN)) diff --git a/wpclib.h b/wpclib.h index 6101f4e..6fc7985 100644 --- a/wpclib.h +++ b/wpclib.h @@ -3,8 +3,8 @@ #define _WPCLIB_H int udp_socket_create (int port); -int udp_socket_send (int s, int dstport, const void *data, int len); -int udp_socket_receive (int s, int dstport, void *data, int len); +int udp_socket_send (int s, int dstport, const void *data, socklen_t len); +int udp_socket_receive (int s, int dstport, void *data, socklen_t len); int udp_socket_close (int s); #define NUM_DMD_PHASES 3 From e0060237b1a63e5118f85f35fd8eeb45b30a81f6 Mon Sep 17 00:00:00 2001 From: nils-eilers Date: Wed, 14 Dec 2016 17:33:34 +0100 Subject: [PATCH 55/71] Ensure that we compile C in C99 mode --- configure.ac | 1 + 1 file changed, 1 insertion(+) diff --git a/configure.ac b/configure.ac index f56ddd5..c078e27 100644 --- a/configure.ac +++ b/configure.ac @@ -6,6 +6,7 @@ AC_CONFIG_HEADER([config.h]) # Checks for programs. AC_PROG_CC +AC_PROG_CC_C99 # Checks for header files. AC_HEADER_STDC From ebd980a30a3eeb8f9bd380465e7c4cee112b43a9 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Wed, 14 Dec 2016 21:20:01 +0000 Subject: [PATCH 56/71] First part of support for Fixed RAM Top in multicomp09 MMU. --- miscsbc.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/miscsbc.c b/miscsbc.c index 6433f32..d0c2621 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -11,6 +11,7 @@ int smii_o_busy = 0; // for multicomp09 sdmapper: values most-recently written to these registers #define MULTICOMP09_RAMMAX (0x80000) unsigned char mc_mmuadr = 0x00; +unsigned char mc_mmufrt = 0x00; // Magic flag for Fixed RAM Top unsigned char mc_mmudat = 0x00; unsigned char mc_timer = 0x00; unsigned char mc_pblk[16]; // [7] is protect, [6:0] is physical block @@ -435,9 +436,22 @@ void sdmapper_remap(int op, int val) if (op == 2) { + if ( ((mc_mmuadr & 0xa0) == 0xa0) && ((val & 0xa0) == 0x20) ) { + // ROMDIS=1 and MMUEn=1 and wrote ROMDIS=0 and MMUEn=1 - cue to + // set FRT bit and IGNORE transition of ROMDIS + mc_mmufrt = 1; + val = val | 0x80; + fprintf(log_file,"INFO mmuadr 0x%02x->0x%02x frt=%1x pc=0x%04x\n", mc_mmuadr, val, mc_mmufrt, get_pc()); + } + if ( (val & 0x20) == 0x00 ) { + // MMUEn is disabled - cue to clear FRT bit + mc_mmufrt = 0; + fprintf(log_file,"INFO mmuadr 0x%02x->0x%02x frt=%1x pc=0x%04x\n", mc_mmuadr, val, mc_mmufrt, get_pc()); + } + // If ROMDIS, TR or MMUEN have changed, report the mapping if ((mc_mmuadr & 0x70) != (val & 0x70)) { - fprintf(log_file,"INFO mmuadr 0x%02x->0x%02x pc=0x%04x", mc_mmuadr, val, get_pc()); + fprintf(log_file,"INFO mmuadr 0x%02x->0x%02x frt=%1x pc=0x%04x", mc_mmuadr, val, mc_mmufrt, get_pc()); for (i=0;i<16;i++) { fprintf(log_file," %02d:0x%02x",i,mc_pblk[i]); } From 8045190ef486cd50df6de5565a72864b5ae56e65 Mon Sep 17 00:00:00 2001 From: nils-eilers Date: Thu, 12 Jan 2017 10:28:23 +0100 Subject: [PATCH 57/71] Remove hardcoded path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There’s no /lib on OS X --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index c078e27..81d4b9c 100644 --- a/configure.ac +++ b/configure.ac @@ -48,7 +48,7 @@ AC_ARG_ENABLE([readline], [rl_lib=$enableval], [rl_lib=no]) if test $rl_lib = yes; then AC_DEFINE(HAVE_READLINE, 1, [Use readline library]) - READLINE_LIBS="-L/lib -lreadline" + READLINE_LIBS="-lreadline" AC_SUBST(READLINE_LIBS) fi From 771225f6b54b963ce5f8daff3efe41e715b25002 Mon Sep 17 00:00:00 2001 From: nils-eilers Date: Thu, 12 Jan 2017 10:29:00 +0100 Subject: [PATCH 58/71] Add a build script for OS X --- README | 15 +++++++++++++++ build.osx.sh | 7 +++++++ 2 files changed, 22 insertions(+) create mode 100755 build.osx.sh diff --git a/README b/README index 2d27bcc..b748bf8 100644 --- a/README +++ b/README @@ -25,6 +25,21 @@ debugger command-line: > ./configure --enable-readline > make +----------------------------------------------------------------- +Build and install (on OS X) + +The build process is very similar to Linux, so the instructions +provided there apply to some degree to OS X as well. + +To automate the process of fetching and installing the +prerequisites, configuring, compiling and installing, a script +exists that does all the grunt work. + +MacPorts is required. Installing the prerequisites requires root +privileges, so you will be asked for your password. + +> ./build.osx.sh + ----------------------------------------------------------------- Input Files diff --git a/build.osx.sh b/build.osx.sh new file mode 100755 index 0000000..6a6bd23 --- /dev/null +++ b/build.osx.sh @@ -0,0 +1,7 @@ +#!/bin/sh +sudo port install readline autoconf automake +automake --add-missing +autoreconf --force +./configure --enable-readline --enable-6309 --libdir=/opt/local/lib --prefix=/opt/gcc6809 +make +sudo make install From d8637bec8cc0567c841379e4021de0ff5fbece3d Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Thu, 19 Jan 2017 21:28:25 +0000 Subject: [PATCH 59/71] Report PC when watchpoint is hit; useful when using watchpoint with 'print' option --- command.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/command.c b/command.c index c6565c5..a1141cd 100644 --- a/command.c +++ b/command.c @@ -1588,7 +1588,7 @@ void command_read_hook (absolute_address_t addr) br = brkfind_by_addr (addr); if (br && br->enabled && br->on_read) { - printf ("Watchpoint %d triggered. [", br->id); + printf ("Watchpoint %d triggered. [pc=0x%04X ", br->id, get_pc()); print_addr (addr); printf ("]\n"); breakpoint_hit (br); @@ -1615,10 +1615,9 @@ void command_write_hook (absolute_address_t addr, U8 val) breakpoint_hit (br); - printf ("Watchpoint %d triggered. [", br->id); + printf ("Watchpoint %d triggered. [pc=0x%04X ", br->id, get_pc()); print_addr (addr); - printf (" = 0x%02X", val); - printf ("]\n"); + printf (" = 0x%02X]\n", val); } } From 660467cd53210edcfa2725a0dcb14eca96e22be7 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Thu, 26 Jan 2017 20:06:53 +0000 Subject: [PATCH 60/71] fix typos in UART reporting. Make message more useful. Change address printing to 4 characters instead of 8. --- miscsbc.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index d5e11a3..7a04838 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -255,7 +255,7 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) /* Other (should be unreachable) -----*/ default: - printf("ERROR in console_read with addr=0x%08x\n", (unsigned int)addr); + printf("ERROR in console_read with addr=0x%04x\n", (unsigned int)addr); return 0x42; } } @@ -271,7 +271,7 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va printf("[uart0 reset]"); } else { - printf("[uart0 stat wr of 0x%02x\n", val); + printf("[uart0 stat wr: PC=0x%04x, addr=0x%04x, wdata=0x%02x]\n", get_pc(), (unsigned int)addr, val); } break; @@ -283,10 +283,10 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va /* UART1 -----------------------------*/ case 2: /* status */ if (val==3) { - printf("[uart0 reset]"); + printf("[uart1 reset]"); } else { - printf("[uart0 stat wr of 0x%02x\n", val); + printf("[uart1 stat wr: PC=0x%04x, addr=0x%04x, wdata=0x%02x]\n", get_pc(), (unsigned int)addr, val); } break; @@ -297,26 +297,26 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va /* UART2 -----------------------------*/ case 4: /* status */ if (val==3) { - printf("[uart0 reset]"); + printf("[uart2 reset]"); } else { - printf("[uart0 stat wr of 0x%02x\n", val); + printf("[uart2 stat wr: PC=0x%04x, addr=0x%04x, wdata=0x%02x]\n", get_pc(), (unsigned int)addr, val); } break; case 5: /* data */ - printf("[uart1 data wr of 0x%02x\n", val); + printf("[uart2 data wr of 0x%02x\n", val); break; /* GPIO (not modelled) ---------------*/ case 6: case 7: - printf("[gpio wr addr=0x%08x val=0x%02x]\n", (unsigned int)addr, val); + printf("[gpio wr addr=0x%04x val=0x%02x]\n", (unsigned int)addr, val); break; /* Other (should be unreachable) -----*/ default: - printf("ERROR in console_write with addr=0x%08x val=0x%02x\n",(unsigned int)addr, val); + printf("ERROR in console_write with addr=0x%04x val=0x%02x\n",(unsigned int)addr, val); } } @@ -599,7 +599,7 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_timer); return mc_timer; default: - printf("INFO In sdmapper_read with addr=0x%08x\n", (unsigned char)addr); + printf("INFO In sdmapper_read with addr=0x%04x\n", (unsigned int)addr); //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x42); } return 0x42; // return default value From a9f8910ff08ee89e603efca9329b640a07bbd4a1 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Wed, 1 Feb 2017 22:02:38 +0000 Subject: [PATCH 61/71] Complete the implementation of Fixed RAM Top. Clean up the code associated with the memory mapping. NitrOS9 now gets through SysGo. --- miscsbc.c | 161 +++++++++++++++++++++++++++++------------------------- 1 file changed, 87 insertions(+), 74 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 7a04838..6e2e400 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -11,6 +11,9 @@ int smii_o_busy = 0; // for multicomp09 sdmapper: values most-recently written to these registers #define MULTICOMP09_RAMMAX (0x80000) +// [NAC HACK 2017Feb01] this does not match RTL!! RTL uses block 7. This is chosen +// for now to match the mapping in NITROS9. +#define FRT_BLOCK (63) unsigned char mc_mmuadr = 0x00; unsigned char mc_mmufrt = 0x00; // Magic flag for Fixed RAM Top unsigned char mc_mmudat = 0x00; @@ -24,9 +27,8 @@ int mc_addr; int mc_state; int mc_poll; int mc_dindex; -// [NAC HACK 2015May07] to allow remap of io. Really nasty hack. -// [NAC HACK 2015May07] also needed to allow dump. -struct hw_device *mc_rom, *mc_ram, *mc_iodev; +// multicomp devices +struct hw_device *mc_romdev, *mc_ramdev, *mc_iodev, *mc_consoledev, *mc_sdmapperdev; FILE *sd_file; FILE *batch_file; @@ -464,56 +466,97 @@ void sdmapper_remap(int op, int val) } - // now update mapping based on mc_mmuadr, mc_pblk[] + // now update mapping based on mc_mmuadr, mc_pblk[], mc_mmufrt //[NAC HACK 2015May06] Yeuch. Horrible how I have had to hardwire the device numbers. //overall, it would be better if I could pick them in the first place. + // 0 null-device + // 1 RAM + // 2 ROM + // 3 CONSOLE + // 4 SDMAPPER + // 5 IOEXPAND // addr dev offset len flags - bus_map(0x0000, 1, mmu_offset(0), 0x2000, mmu_flags(0)); - bus_map(0x2000, 1, mmu_offset(1), 0x2000, mmu_flags(1)); - bus_map(0x4000, 1, mmu_offset(2), 0x2000, mmu_flags(2)); + bus_map(0x0000, 1, mmu_offset(0), 0x2000, mmu_flags(0)); // block 0 + bus_map(0x2000, 1, mmu_offset(1), 0x2000, mmu_flags(1)); // block 1 + bus_map(0x4000, 1, mmu_offset(2), 0x2000, mmu_flags(2)); // .. bus_map(0x6000, 1, mmu_offset(3), 0x2000, mmu_flags(3)); bus_map(0x8000, 1, mmu_offset(4), 0x2000, mmu_flags(4)); bus_map(0xA000, 1, mmu_offset(5), 0x2000, mmu_flags(5)); - bus_map(0xC000, 1, mmu_offset(6), 0x2000, mmu_flags(6)); + bus_map(0xC000, 1, mmu_offset(6), 0x2000, mmu_flags(6)); // block 6 - // 0xE000-0xFFFF ROM or remappable RAM + // Block 7 is cut up in pieces.. + + // 0xE000-0xFDFF (0x1E00 bytes) behaves as ROM or MMappable RAM + if (mc_mmuadr & 0x80) { + // ROM device disabled; map RAM. + bus_map(0xE000, 1, mmu_offset(7), 0x1E00, mmu_flags(7)); + } + else { + // ROM device, starting at offset 0 + bus_map(0xE000, 2, 0x0000, 0x1E00, MAP_READABLE); + } + + // The next 0x180 bytes is the first part of the Fixed RAM Top + // which behaves as ROM or MMappable RAM or RAM from a fixed block if (mc_mmuadr & 0x80) { - // ROM disabled; map RAM. - bus_map(0xE000, 1, mmu_offset(7), 0x2000, mmu_flags(7)); + // ROM device disabled; map 0x180 bytes of RAM + if (mc_mmufrt) { + // RAM from fixed block -- always allow read/write + bus_map(0xFE00, 1, 0x1E00 + (FRT_BLOCK << 13), 0x180, mmu_flags(7)); + } + else { + // RAM from block controlled by MMU + bus_map(0xFE00, 1, 0x1E00 + mmu_offset(7), 0x180, MAP_READWRITE); + } } else { - // ROM - bus_map(0xE000, 2, 0x0000, 0x2000, MAP_READABLE); // ROM + // ROM device, starting at offset 0x1E00 + bus_map(0xFE00, 2, 0x1E00, 0x180, MAP_READABLE); } - // need to do IOEXPAND last because it overwrites a section within - // a larger window. - bus_map(0xFF80, 5, 0x0000, 128, MAP_READWRITE); // IOEXPAND + // The final 0x80 bytes at the very top of the address space is broken + // into 16 devices, each 8 bytes in size. Two of the devices correspond + // to addresses 0xFFDx -- the I/O devices. The remaining 14 slots act + // in the same way as Fixed RAM Top and each of them applies the same + // rules as the other FRT region above. + bus_map(0xFF80, 5, 0x0000, 128, MAP_READWRITE); // ioexpand - // need to do this again for the windows that map back - // to underlying ROM.. because it may now be underlying RAM for (i=0; i<16; i++) { - if ((i!=10) && (i!=11)) { - // Map to underlying memory. Read will have an address of 0x0-0xf - // so we need to apply an offset to get it to the - // right place. The offset is from the start of the - // romdev and has nothing to do with the actual - // bus address of the location. - // Access permission inherited from underlying - // device, which is exactly what I want. + if (i==10) { + // 0xFFD0-0xFFD7 -- VDU/UART and GPIO + ioexpand_attach(mc_iodev, i, 0, mc_consoledev); + } + else if (i==11) { + // 0xFFD8-0xFFDF -- SDCARD and MemMapper + ioexpand_attach(mc_iodev, i, 0, mc_sdmapperdev); + } + else { + // Map to underlying memory. Access will have an address of 0x0-0xf + // so we need to apply an offset to get it to the right place. The + // offset is from the start of the underlying device (ROM or RAM) + // and has nothing to do with the actual bus address of the location. + // The access permissions are inherited from the underlying device, + // which is exactly what I want. + // [NAC HACK 2017Feb01] is the access permission correct for the + // write-protection flag on the MMU devices?? if (mc_mmuadr & 0x80) { - // ROM is disabled; map RAM. Offset is a function of paging register - // [NAC HACK 2015Jun26] was: - // ioexpand_attach(mc_iodev, i, ((mc_mapper & 0xf0)<<9) + 0x1F80 + (i*8), mc_ram); - ioexpand_attach(mc_iodev, i, mmu_offset(7) + 0x1F80 + (i*8), mc_ram); + // ROM device disabled; map 0x10 bytes of RAM + if (mc_mmufrt) { + // RAM from fixed block -- always allow read/write + ioexpand_attach(mc_iodev, i, (FRT_BLOCK << 13) + 0x1F80 + (i*8), mc_ramdev); + } + else { + // RAM from block controlled by MMU + ioexpand_attach(mc_iodev, i, mmu_offset(7) + 0x1F80 + (i*8), mc_ramdev); + } } else { - // ROM - ioexpand_attach(mc_iodev, i, 0x1F80 + (i*8), mc_rom); + // ROM device, starting at offset 0x1F80 + ioexpand_attach(mc_iodev, i, 0x1F80 + (i*8), mc_romdev); } } } @@ -746,16 +789,12 @@ struct hw_device* sdmapper_create (void) } + // [NAC HACK 2015May05] is it legal to have more than one instance of anything? // eg 2 RAMs? I assumed it was but now I realise IT IS NOT! Yeuch. // I assume the same restriction also applies to ROMs and RAMs void multicomp09_init (const char *boot_rom_file) { - struct hw_device* multicomp09_console; - struct hw_device* multicomp09_sdmapper; - struct hw_device* iodev; - struct hw_device* ramdev; - struct hw_device* romdev; int i; /* Log file @@ -767,22 +806,22 @@ void multicomp09_init (const char *boot_rom_file) otherwise, it is mapped in 8K chunks. Each chunk has a separate write protect. */ - ramdev = ram_create(MULTICOMP09_RAMMAX); + mc_ramdev = ram_create(MULTICOMP09_RAMMAX); /* ROM is 8Kbytes. Usually sits from E000 to FFFF but can be disabled by writing 0x80 to MMUADR */ - romdev = rom_create (boot_rom_file, 0x2000); + mc_romdev = rom_create (boot_rom_file, 0x2000); - /* I/O - UART */ - multicomp09_console = console_create(); - multicomp09_console->class_ptr->read = multicomp09_console_read; - multicomp09_console->class_ptr->write = multicomp09_console_write; + /* I/O Devices - UARTs */ + mc_consoledev = console_create(); + mc_consoledev->class_ptr->read = multicomp09_console_read; + mc_consoledev->class_ptr->write = multicomp09_console_write; - /* I/O - sdmapper */ - multicomp09_sdmapper = sdmapper_create(); + /* I/O Devices - SD controller, MMapper, Timer */ + mc_sdmapperdev = sdmapper_create(); - /* I/O devices at FFD0/FFDF + /* Address space for I/O devices at FFD0/FFDF Use an ioexpand device at 0xFF80-0xFFFF. This overlays the ROM mapping and creating it *after* the ROM overwrites the ROM's mapping. @@ -791,40 +830,14 @@ void multicomp09_init (const char *boot_rom_file) In particular, need locations 0xFFF0-0xFFFF mapped in order to provide the exception vectors. */ - iodev = ioexpand_create(); + mc_iodev = ioexpand_create(); - for (i=0; i<16; i++) { - if (i==10) { - // 0xFFD0-0xFFD7 -- VDU/UART and GPIO - ioexpand_attach(iodev, i, 0, multicomp09_console); - } - else if (i==11) { - // 0xFFD8-0xFFDF -- SDCARD and MemMapper - ioexpand_attach(iodev, i, 0, multicomp09_sdmapper); - } - else { - //[NAC HACK 2015May07] done in sdmapper_remap in a moment - // so no real reason to do it here.. - - // Map to ROM. Read will have an address of 0x0-0xf - // so we need to apply an offset to get it to the - // right place. The offset is from the start of the - // romdev and has nothing to do with the actual - // bus address of the location. - ioexpand_attach(iodev, i, 0x1F80 + (i*8), romdev); - } - } - //[NAC HACK 2015May07] need a nicer way than this! - mc_rom = romdev; - mc_ram = ramdev; - mc_iodev = iodev; /* Now map all the devices into the address space, in accordance with the settings of the memory mapper. */ sdmapper_remap(0, 0); - /* If a file multicomp09.bat exists, supply input from it until it's exhausted. */ @@ -852,7 +865,7 @@ void multicomp09_dump (void) char byte; dump_file = file_open(NULL, "multicomp09.dmp", "w+b"); for (i=0; i Date: Fri, 3 Feb 2017 20:49:37 +0000 Subject: [PATCH 62/71] Add new -os9call switch to make SWI2 be reported with a post-byte in disassembly. Thanks to Ole for the idea/code. --- README | 5 +++++ main.c | 5 +++++ monitor.c | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/README b/README index b748bf8..c415383 100644 --- a/README +++ b/README @@ -91,6 +91,11 @@ TODO : Would anyone be interested in a CoCo machine type? Faults +----------------------------------------------------------------- +Command-line options + +Use -help to see the command-line options. + ----------------------------------------------------------------- Debugging diff --git a/main.c b/main.c index 49a73c7..1672372 100644 --- a/main.c +++ b/main.c @@ -48,6 +48,9 @@ int debug_enabled = 0; /* Nonzero if tracing is enabled */ int trace_enabled = 0; +/* Nonzero if SWI2 should be reported with a postbyte */ +int os9call = 0; + /* When nonzero, causes the program to print the total number of cycles on a successful exit. */ int dump_cycles_on_success = 0; @@ -192,6 +195,8 @@ struct option NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL }, { 'C', "cycledump", "", HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL}, + { 'o', "os9call", "Treat SWI2 as an OS9/NitrOS9 system call and report postbyte", + HAS_NEG, NO_ARG, &os9call, 1, NULL, NULL}, { 't', "loadmap", "" }, { 'T', "trace", "", NO_NEG, NO_ARG, &trace_enabled, 1, NULL, NULL }, diff --git a/monitor.c b/monitor.c index ae709a3..ce87fe3 100644 --- a/monitor.c +++ b/monitor.c @@ -897,15 +897,17 @@ int dasm (char *buf, absolute_address_t opc) int fetch1; /* the first (MSB) fetched byte, used in macro RDWORD */ absolute_address_t tmp; + extern int os9call; + op = fetch8(); - if (op == 0x10) + if (op == 0x10) /* prefix for PAGE2 opcodes */ { op = fetch8(); am = codes10[op].mode; op = codes10[op].code; } - else if (op == 0x11) + else if (op == 0x11) /* prefix for PAGE3 opcodes */ { op = fetch8(); am = codes11[op].mode; @@ -918,7 +920,15 @@ int dasm (char *buf, absolute_address_t opc) } op_str = (char *) mne[op]; - buf += sprintf (buf, "%-6.6s", op_str); + if ((op_str == "SWI2") && os9call) + { + op = fetch8(); + buf += sprintf (buf, "%-6.6s#$%2x", "OS9", op); + } + else + { + buf += sprintf (buf, "%-6.6s", op_str); + } switch (am) { From 9254e4b7166a6ccf6f4c9353aa5cdc07fc9b04b9 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Fri, 3 Feb 2017 23:11:13 +0000 Subject: [PATCH 63/71] Prevent spurious FIRQ interrupts when periodic IRQ interrupts are enabled; and vice-versa. Currently do not support enable of perodic IRQ and FIRQ interrupts at the same time. --- main.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 1672372..afee5ee 100644 --- a/main.c +++ b/main.c @@ -22,6 +22,7 @@ #include #include +#include #include "6809.h" #include "command.h" #include "symtab.h" @@ -57,7 +58,7 @@ int dump_cycles_on_success = 0; /* When nonzero, indicates the total number of cycles before an automated exit. This is to help speed through test cases that never finish. */ -unsigned long max_cycles = 500000000UL; +int max_cycles = INT_MAX; /* When nonzero, says that the state of the machine is persistent across runs of the simulator. */ @@ -418,7 +419,7 @@ main (int argc, char *argv[]) * here periodically and do the interrupt handling. */ for (cpu_quit = 1; cpu_quit != 0;) { - if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) + if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) { /* Simulate some CPU time, either 1ms worth or up to the next possible IRQ */ @@ -427,20 +428,22 @@ main (int argc, char *argv[]) /* Call each device that needs periodic processing. */ machine_update (); } - else + else if ((cycles_per_irq != 0) && (cycles_per_firq == 0)) { total += cpu_execute (cycles_per_irq); - /* TODO - this assumes periodic interrupts (WPC) */ request_irq (0); - { - /* TODO - FIRQ frequency not handled yet */ - static int firq_freq = 0; - if (++firq_freq == 8) - { - request_firq (0); - firq_freq = 0; - } - } + } + else if ((cycles_per_irq == 0) && (cycles_per_firq != 0)) + { + total += cpu_execute (cycles_per_firq); + request_firq (0); + } + else + { + /* need to track them both and continue to work out which is + next. + */ + sim_error ("Oops. Don't currently support -I and -F together\n"); } idle_loop (); From f8a30b344bdbff714ccf0069a7f107cdada11008 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Fri, 3 Feb 2017 23:27:17 +0000 Subject: [PATCH 64/71] Perform a crude filter to omit MMU readback warnings that are associated with the read-modify-write behaviour of the CLR instruction.. but only when used with extended addressing. --- miscsbc.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 6e2e400..6e44b5b 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -642,8 +642,17 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_timer); return mc_timer; default: - printf("INFO In sdmapper_read with addr=0x%04x\n", (unsigned int)addr); - //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),0x42); + // In general, it's an error to read back anything else. However, in the + // case of a CLR instruction the CPU does a read "modify" write (but + // ignores the read data. In this case, it's nice *not* to print this + // warning message. + // This is a hack because it only ignores CLR with extended addressing + // and, worse, it might cause a real problem to be missed because + // we guess/assume the start position of the previous op-code (would be + // cleaner if we tracker previous pc). + if (read8(get_pc()-3) != 0x7f) { + printf("INFO In sdmapper_read with addr=0x%04x\n", (unsigned int)addr); + } } return 0x42; // return default value } From 0589c7852985f6e4faacb1fd4703f2a3d3b48b99 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Wed, 8 Feb 2017 21:49:53 +0000 Subject: [PATCH 65/71] Ole's code to report OS9 system calls by name. --- Makefile.in | 2 +- monitor.c | 10 ++- os9syscalls.h | 200 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 210 insertions(+), 2 deletions(-) create mode 100644 os9syscalls.h diff --git a/Makefile.in b/Makefile.in index 891d918..ed5251d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -168,7 +168,7 @@ m6809_run_SOURCES = \ 6809.c main.c monitor.c machine.c eon.c wpc.c miscsbc.c \ symtab.c command.c fileio.c wpclib.c imux.c \ ioexpand.c mmu.c timer.c serial.c disk.c \ - 6809.h config.h eon.h machine.h monitor.h wpclib.h + 6809.h config.h eon.h machine.h monitor.h os9syscalls.h wpclib.h bin_SCRIPTS = wpc-run all: config.h diff --git a/monitor.c b/monitor.c index ce87fe3..6f92329 100644 --- a/monitor.c +++ b/monitor.c @@ -24,6 +24,7 @@ #include "6809.h" #include "monitor.h" #include "command.h" +#include "os9syscalls.h" /* The function call stack */ struct function_call fctab[MAX_FUNCTION_CALLS]; @@ -923,7 +924,14 @@ int dasm (char *buf, absolute_address_t opc) if ((op_str == "SWI2") && os9call) { op = fetch8(); - buf += sprintf (buf, "%-6.6s#$%2x", "OS9", op); + if(op < 0x91) + { + buf += sprintf (buf, "%-6.6s%s", "OS9", os9syscall[op]); + } + else + { + buf += sprintf (buf, "%-6.6s#$%2x", "OS9", op); + } } else { diff --git a/os9syscalls.h b/os9syscalls.h new file mode 100644 index 0000000..33d1eb7 --- /dev/null +++ b/os9syscalls.h @@ -0,0 +1,200 @@ +/******************************************************************** +* os9.h - NitrOS-9 System Definitions +* +* $Id$ +* +* Edt/Rev YYYY/MM/DD Modified by +* Comment +* ------------------------------------------------------------------ +*/ +/* ORG 0 */ +char *os9syscall[] = { +"F$Link", /* $00 Link to Module */ +"F$Load", /* $01 Load Module from File */ +"F$UnLink", /* $02 Unlink Module */ +"F$Fork", /* $03 Start New Process */ +"F$Wait", /* $04 Wait for Child Process to Die */ +"F$Chain", /* $05 Chain Process to New Module */ +"F$Exit", /* $06 Terminate Process */ +"F$Mem", /* $07 Set Memory Size */ +"F$Send", /* $08 Send Signal to Process */ +"F$Icpt", /* $09 Set Signal Intercept */ +"F$Sleep", /* $0A Suspend Process */ +"F$SSpd", /* $0B Suspend Process */ +"F$ID", /* $0C Return Process ID */ +"F$SPrior", /* $0D Set Process Priority */ +"F$SSWI", /* $0E Set Software Interrupt */ +"F$PErr", /* $0F Print Error */ +"F$PrsNam", /* $10 Parse Pathlist Name */ +"F$CmpNam", /* $11 Compare Two Names */ +"F$SchBit", /* $12 Search Bit Map */ +"F$AllBit", /* $13 Allocate in Bit Map */ +"F$DelBit", /* $14 Deallocate in Bit Map */ +"F$Time", /* $15 Get Current Time */ +"F$STime", /* $16 Set Current Time */ +"F$CRC", /* $17 Generate CRC ($17) */ + +/* IFGT Level-1 */ + + /* NitrOS-9 Level 2 system calls */ +"F$GPrDsc", /* $18 Get Process Descriptor copy ($18) */ +"F$GBlkMp", /* $19 Get System Block Map copy ($19) */ +"F$GModDr", /* $1A Get Module Directory copy ($1A) */ +"F$CpyMem", /* $1B Copy External Memory ($1B) */ +"F$SUser", /* $1C Set User ID number ($1C) */ +"F$UnLoad", /* $1D Unlink Module by name ($1D) */ +"F$Alarm", /* $1E Color Computer 3 Alarm Call ($1E) */ +"F$1F", /* $1F RMB 1 Reserved - For overlap of other systems ($1F) */ +"F$20", /* $20 RMB 1 Reserved - For overlap of other systems ($1F) */ +"F$NMLink", /* $21 Color Computer 3 Non-Mapping Link ($21) */ +"F$NMLoad", /* $22 Color Computer 3 Non-Mapping Load ($22) */ + +/* ELSE + +* NitrOS-9 Level 1 system call padding + RMB 11 + + ENDC +*/ + +"F$Debu", /* $23 Drop the system into the debugger ($23) */ +"F$24", /* $24 Dummy */ + +/* IFGT Level-1 + + ORG $25 */ +"F$TPS", /* $25 Return System's Ticks Per Second */ +"F$TimAlm", /* $26 CoCo individual process alarm call */ + +/* ENDC */ + + /* ORG $27 Beginning of System Reserved Calls */ +/* NitrOS-9 common system calls */ +"F$VIRQ", /* $27 Install/Delete Virtual IRQ */ +"F$SRqMem", /* $28 System Memory Request */ +"F$SRtMem", /* $29 System Memory Return */ +"F$IRQ", /* $2A Enter IRQ Polling Table */ +"F$IOQu", /* $2B Enter I/O Queue */ +"F$AProc", /* $2C Enter Active Process Queue */ +"F$NProc", /* $2D Start Next Process */ +"F$VModul", /* $2E Validate Module */ +"F$Find64", /* $2f Find Process/Path Descriptor */ +"F$All64", /* $30 Allocate Process/Path Descriptor */ +"F$Ret64", /* $31 Return Process/Path Descriptor */ +"F$SSvc", /* $32 Service Request Table Initialization */ +"F$IODel", /* $33 Delete I/O Module */ + + /* IFGT Level-1 */ + +"F$SLink", /* $34 System Link */ +"F$Boot", /* $35 Bootstrap System */ +"F$BtMem", /* $36 Bootstrap Memory Request */ +"F$GProcP", /* $37 Get Process ptr */ +"F$Move", /* $38 Move Data (low bound first) */ +"F$AllRAM", /* $39 Allocate RAM blocks */ +"F$AllImg", /* $3A Allocate Image RAM blocks */ +"F$DelImg", /* $3B Deallocate Image RAM blocks */ +"F$SetImg", /* $3C Set Process DAT Image */ +"F$FreeLB", /* $3D Get Free Low Block */ +"F$FreeHB", /* $3E Get Free High Block */ +"F$AllTsk", /* $3F Allocate Process Task number */ +"F$DelTsk", /* $40 Deallocate Process Task number */ +"F$SetTsk", /* $41 Set Process Task DAT registers */ +"F$ResTsk", /* $42 Reserve Task number */ +"F$RelTsk", /* $43 Release Task number */ +"F$DATLog", /* $44 Convert DAT Block/Offset to Logical */ +"F$DATTmp", /* $45 Make temporary DAT image (Obsolete) */ +"F$LDAXY", /* $46 Load A [X,[Y]] */ +"F$LDAXYP", /* $47 Load A [X+,[Y]] */ +"F$LDDDXY", /* $48 Load D [D+X,[Y]] */ +"F$LDABX", /* $49 Load A from 0,X in task B */ +"F$STABX", /* $4A Store A at 0,X in task B */ +"F$AllPrc", /* $4B Allocate Process Descriptor */ +"F$DelPrc", /* $4C Deallocate Process Descriptor */ +"F$ELink", /* $4D Link using Module Directory Entry */ +"F$FModul", /* $4E Find Module Directory Entry */ +"F$MapBlk", /* $4F Map Specific Block */ +"F$ClrBlk", /* $50 Clear Specific Block */ +"F$DelRAM", /* $51 Deallocate RAM blocks */ +"F$GCMDir", /* $52 Pack module directory */ +"F$AlHRAM", /* $53 Allocate HIGH RAM Blocks */ + +/* Alan DeKok additions */ +"F$ReBoot", /* $54 Reboot machine (reload OS9Boot) or drop to RSDOS */ +"F$CRCMod", /* $55 CRC mode, toggle or report current status */ +"F$XTime", /* $56 Get Extended time packet from RTC (fractions of second) */ +"F$VBlock", /* $57 Verify modules in a block of memory, add to module directory */ +"F$58", +"F$59", +"F$5A", +"F$5B", +"F$5C", +"F$5D", +"F$5E", +"F$5F", +"F$60", +"F$61", +"F$62", +"F$63", +"F$64", +"F$65", +"F$66", +"F$67", +"F$68", +"F$69", +"F$6A", +"F$6B", +"F$6C", +"F$6D", +"F$6E", +"F$6F", + + /* ENDC +* +* Numbers $70 through $7F are reserved for user definitions +* + ORG $70 + IFEQ Level-1 + RMB 16 Reserved for user definition + ELSE */ + +"F$RegDmp", /* $70 Ron Lammardo's debugging register dump */ +"F$NVRAM", /* $71 Non Volatile RAM (RTC battery backed static) read/write */ +"F$72", +"F$73", +"F$74", +"F$75", +"F$76", +"F$77", +"F$78", +"F$79", +"F$7A", +"F$7B", +"F$7C", +"F$7D", +"F$7E", +"F$7F", + + +/************************************** +* I/O Service Request Code Definitions +*/ +/* ORG $80 */ +"I$Attach", /* $80 Attach I/O Device */ +"I$Detach", /* $81 Detach I/O Device */ +"I$Dup", /* $82 Duplicate Path */ +"I$Create", /* $83 Create New File */ +"I$Open", /* $84 Open Existing File */ +"I$MakDir", /* $85 Make Directory File */ +"I$ChgDir", /* $86 Change Default Directory */ +"I$Delete", /* $87 Delete File */ +"I$Seek", /* $88 Change Current Position */ +"I$Read", /* $89 Read Data */ +"I$Write", /* $8A Write Data */ +"I$ReadLn", /* $8B Read Line of ASCII Data */ +"I$WritLn", /* $8C Write Line of ASCII Data */ +"I$GetStt", /* $8D Get Path Status */ +"I$SetStt", /* $8E Set Path Status */ +"I$Close", /* $8F Close Path */ +"I$DeletX", /* $90 Delete from current exec dir */ +}; From b2ddb4edd8c0f8a35fae5644f44655bfb11a5437 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Sat, 11 Feb 2017 23:30:52 +0000 Subject: [PATCH 66/71] Add support for character type ('c') in examine command - can now do ASCII dump like this: x/32c 0x100 --- README | 2 +- command.c | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/README b/README index c415383..9237649 100644 --- a/README +++ b/README @@ -188,7 +188,7 @@ p [format] - use the previous format. f is the display format (default x for hex). Options: - x X d u o a s (match printf). + x X d u o a c s (match printf). TODO: the code supports /u (unit) as well, but the b w options don't make any obvious difference to the output. diff --git a/command.c b/command.c index a1141cd..fce83bc 100644 --- a/command.c +++ b/command.c @@ -229,6 +229,7 @@ void parse_format_flag (const char *flags, unsigned char *formatp) case 'o': case 'a': case 's': + case 'c': *formatp = *flags; break; } @@ -535,6 +536,15 @@ void print_value (unsigned long val, datatype_t *typep) print_addr (val); return; + case 'c': + { + char c; + c = val; + if ((c < 32) | (c > 126)) c = '.'; + putchar(c); + return; + } + case 's': { absolute_address_t addr = (absolute_address_t)val; @@ -625,6 +635,10 @@ void do_examine (void) case 'w': objs_per_line = 8; break; + + case 'c': + objs_per_line = 32; + break; } for (n = 0; n < examine_repeat; n++) @@ -648,7 +662,7 @@ void do_examine (void) default: print_value (target_read (examine_addr, examine_type.size), &examine_type); - putchar (' '); + if (examine_type.format != 'c') putchar (' '); examine_addr += examine_type.size; } } From 523ee130a073fa98ae3ed4d1e76434a33c64a8e6 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Tue, 14 Mar 2017 20:17:34 +0000 Subject: [PATCH 67/71] First attempt at CWAI implementation. Seems to run the NITROS9 level1 kernel time OK. --- 6809.c | 209 +++++++++++++++++++++++++++++---------------------------- 6809.h | 5 ++ 2 files changed, 110 insertions(+), 104 deletions(-) diff --git a/6809.c b/6809.c index 0d8f962..e1f5c5e 100644 --- a/6809.c +++ b/6809.c @@ -51,11 +51,13 @@ unsigned int cc_changed = 0; unsigned *index_regs[4] = { &X, &Y, &U, &S }; +int cwai_state = CWAI_STATE_IDLE; + extern int dump_cycles_on_success; extern int trace_enabled; -extern void irq (void); -extern void firq (void); +void irq (void); +void firq (void); void request_irq (unsigned int source) @@ -66,7 +68,7 @@ void request_irq (unsigned int source) */ irqs_pending |= (1 << source); if (!(EFI & I_FLAG)) - irq (); + irq(); } void release_irq (unsigned int source) @@ -82,7 +84,7 @@ void request_firq (unsigned int source) */ firqs_pending |= (1 << source); if (!(EFI & F_FLAG)) - firq (); + firq(); } void release_firq (unsigned int source) @@ -597,9 +599,9 @@ void cc_modified (void) { /* Check for pending interrupts */ if (firqs_pending && !(EFI & F_FLAG)) - firq (); + firq(); else if (irqs_pending && !(EFI & I_FLAG)) - irq (); + irq(); cc_changed = 0; } @@ -1340,6 +1342,36 @@ static void pulu (void) /* Miscellaneous Instructions */ +static void stack_machine_state(int full) +{ + if (full) { + cpu_clk -= 19; + EFI |= E_FLAG; + } + else { + cpu_clk -= 6; /* ?? */ + EFI &= ~E_FLAG; + } + S = (S - 2) & 0xffff; + write_stack16(S, PC & 0xffff); + if (full) { + S = (S - 2) & 0xffff; + write_stack16(S, U); + S = (S - 2) & 0xffff; + write_stack16(S, Y); + S = (S - 2) & 0xffff; + write_stack16(S, X); + S = (S - 1) & 0xffff; + write_stack(S, DP >> 8); + S = (S - 1) & 0xffff; + write_stack(S, B); + S = (S - 1) & 0xffff; + write_stack(S, A); + } + S = (S - 1) & 0xffff; + write_stack(S, get_cc()); +} + static void nop (void) { cpu_clk -= 2; @@ -1393,27 +1425,17 @@ static void rts (void) void irq (void) { - EFI |= E_FLAG; - S = (S - 2) & 0xffff; - write_stack16 (S, PC & 0xffff); - S = (S - 2) & 0xffff; - write_stack16 (S, U); - S = (S - 2) & 0xffff; - write_stack16 (S, Y); - S = (S - 2) & 0xffff; - write_stack16 (S, X); - S = (S - 1) & 0xffff; - write_stack (S, DP >> 8); - S = (S - 1) & 0xffff; - write_stack (S, B); - S = (S - 1) & 0xffff; - write_stack (S, A); - S = (S - 1) & 0xffff; - write_stack (S, get_cc ()); + if (cwai_state == CWAI_STATE_WAIT) { + /* In CWAI and machine state is already saved */ + cwai_state = CWAI_STATE_IDLE; + } + else { + stack_machine_state(1); + } EFI |= I_FLAG; - irq_start_time = get_cycles (); - change_pc (read16 (0xfff8)); + irq_start_time = get_cycles(); + change_pc(read16(0xfff8)); #if 1 irqs_pending = 0; #endif @@ -1421,14 +1443,16 @@ void irq (void) void firq (void) { - EFI &= ~E_FLAG; - S = (S - 2) & 0xffff; - write_stack16 (S, PC & 0xffff); - S = (S - 1) & 0xffff; - write_stack (S, get_cc ()); + if (cwai_state == CWAI_STATE_WAIT) { + /* In CWAI and machine state is already saved */ + cwai_state = CWAI_STATE_IDLE; + } + else { + stack_machine_state(0); + } EFI |= (I_FLAG | F_FLAG); - change_pc (read16 (0xfff6)); + change_pc(read16(0xfff6)); #if 1 firqs_pending = 0; #endif @@ -1436,24 +1460,7 @@ void firq (void) void swi (void) { - cpu_clk -= 19; - EFI |= E_FLAG; - S = (S - 2) & 0xffff; - write_stack16 (S, PC & 0xffff); - S = (S - 2) & 0xffff; - write_stack16 (S, U); - S = (S - 2) & 0xffff; - write_stack16 (S, Y); - S = (S - 2) & 0xffff; - write_stack16 (S, X); - S = (S - 1) & 0xffff; - write_stack (S, DP >> 8); - S = (S - 1) & 0xffff; - write_stack (S, B); - S = (S - 1) & 0xffff; - write_stack (S, A); - S = (S - 1) & 0xffff; - write_stack (S, get_cc ()); + stack_machine_state(1); EFI |= (I_FLAG | F_FLAG); change_pc (read16 (0xfffa)); @@ -1461,48 +1468,16 @@ void swi (void) void swi2 (void) { - cpu_clk -= 20; - EFI |= E_FLAG; - S = (S - 2) & 0xffff; - write_stack16 (S, PC & 0xffff); - S = (S - 2) & 0xffff; - write_stack16 (S, U); - S = (S - 2) & 0xffff; - write_stack16 (S, Y); - S = (S - 2) & 0xffff; - write_stack16 (S, X); - S = (S - 1) & 0xffff; - write_stack (S, DP >> 8); - S = (S - 1) & 0xffff; - write_stack (S, B); - S = (S - 1) & 0xffff; - write_stack (S, A); - S = (S - 1) & 0xffff; - write_stack (S, get_cc ()); + cpu_clk -= 1; + stack_machine_state(1); change_pc (read16 (0xfff4)); } void swi3 (void) { - cpu_clk -= 20; - EFI |= E_FLAG; - S = (S - 2) & 0xffff; - write_stack16 (S, PC & 0xffff); - S = (S - 2) & 0xffff; - write_stack16 (S, U); - S = (S - 2) & 0xffff; - write_stack16 (S, Y); - S = (S - 2) & 0xffff; - write_stack16 (S, X); - S = (S - 1) & 0xffff; - write_stack (S, DP >> 8); - S = (S - 1) & 0xffff; - write_stack (S, B); - S = (S - 1) & 0xffff; - write_stack (S, A); - S = (S - 1) & 0xffff; - write_stack (S, get_cc ()); + cpu_clk -= 1; + stack_machine_state(1); change_pc (read16 (0xfff2)); } @@ -1510,32 +1485,58 @@ void swi3 (void) #ifdef H6309 void trap (void) { - cpu_clk -= 20; - EFI |= E_FLAG; - S = (S - 2) & 0xffff; - write_stack16 (S, PC & 0xffff); - S = (S - 2) & 0xffff; - write_stack16 (S, U); - S = (S - 2) & 0xffff; - write_stack16 (S, Y); - S = (S - 2) & 0xffff; - write_stack16 (S, X); - S = (S - 1) & 0xffff; - write_stack (S, DP >> 8); - S = (S - 1) & 0xffff; - write_stack (S, B); - S = (S - 1) & 0xffff; - write_stack (S, A); - S = (S - 1) & 0xffff; - write_stack (S, get_cc ()); + cpu_clk -= 1; + stack_machine_state(1); change_pc (read16 (0xfff0)); } #endif +/* CWAI handling is controlled by a variable cwai_state and divided + into 3 parts: + - code here + - code in the main instruction loop + - code in irq() and firq() + + CWAI masks the CC then saves all of the user registers on the + hardware stack and waits for interrupt (so that the interrupt has lower + latency). + + [NAC HACK 2017Mar11] should abort main loop here when CWAI_STATE_WAIT + otherwise we're simply burning cycles to no benefit + [NAC HACK 2017Mar11] need to fix other bugs in main scheduler? + [NAC HACK 2017Mar11] why doesn't nitros L1 work now? Doesn't get any + I/O? Do I need to mock up a serial interrupt? I thought it was all + done on the timer? +*/ void cwai (void) { - sim_error ("CWAI - not supported yet!"); + switch (cwai_state) { + case CWAI_STATE_IDLE: + /* PC has advanced to this CWAI instruction. Set flags, + stack machine state for when we take the interrupt; the + stacked PC points after the CWAI + */ + EFI &= (INT8) imm_byte (); + cpu_clk -= 1; + stack_machine_state(1); + + /* remember we're in CWAI, adjust PC to re-execute this instruction + */ + cwai_state = CWAI_STATE_WAIT; + change_pc (PC - 2); /* instruction + immediate */ + break; + case CWAI_STATE_WAIT: + /* Been here before. Still waiting for interrupt. Adjust PC so that + we will re-execute this instruction + */ + cpu_clk -= 1; /* [NAC HACK 2017Mar11] not correct.. */ + change_pc (PC - 1); /* instruction -- did not fetch immediate */ + break; + default: + sim_error ("invalid value of cwai_state %02X\n", cwai_state); + break; + } } void sync (void) diff --git a/6809.h b/6809.h index bea5bec..4d4551e 100644 --- a/6809.h +++ b/6809.h @@ -63,6 +63,11 @@ typedef uint16_t target_addr_t; #define V_FLAG 0x02 #define C_FLAG 0x01 +/* For cwai state machine */ +#define CWAI_STATE_IDLE 0 +#define CWAI_STATE_WAIT 1 + + extern int debug_enabled; extern int need_flush; extern unsigned long total; From 9a1d1a55729eb572375de5f67fbc24b7ced73f7e Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Tue, 28 Mar 2017 23:57:22 +0100 Subject: [PATCH 68/71] Model Rx FIFO for mc09 uart0. Add infrastructure to allow Rx interrupts when the FIFO is non-empty. Has only undergone brief testing but seems to work well enough not to break polled code and to allow NITROS9 L2 to boot to the shell, and FUZIX to continue to boot. --- 6809.c | 18 +++++ command.c | 2 +- machine.c | 1 + main.c | 5 +- miscsbc.c | 194 +++++++++++++++++++++++++++++++++++++++++++----------- 5 files changed, 178 insertions(+), 42 deletions(-) diff --git a/6809.c b/6809.c index e1f5c5e..ddb1cd8 100644 --- a/6809.c +++ b/6809.c @@ -59,7 +59,16 @@ extern int trace_enabled; void irq (void); void firq (void); +/* [NAC HACK 2017Mar28] crude mechanism to allow multicomp09 + to model the timer interrupt +*/ +unsigned int wot_irqs(void) +{ + return irqs_pending; +} +/* called with source=0 for periodic timer interrupt */ +/* called with source=1 for multicomp09 uart0 rx interrupt */ void request_irq (unsigned int source) { /* If the interrupt is not masked, generate @@ -71,11 +80,16 @@ void request_irq (unsigned int source) irq(); } +/* currently this is never called. Instead, irqs_pending is + always cleared in the ISR. That matches an ISR that processes + to completion +*/ void release_irq (unsigned int source) { irqs_pending &= ~(1 << source); } +/* called with source=0 for periodic timer interrupt */ void request_firq (unsigned int source) { /* If the interrupt is not masked, generate @@ -87,6 +101,10 @@ void request_firq (unsigned int source) firq(); } +/* currently this is never called. Instead, irqs_pending is + always cleared in the ISR. That matches an ISR that processes + to completion +*/ void release_firq (unsigned int source) { firqs_pending &= ~(1 << source); diff --git a/command.c b/command.c index fce83bc..0143997 100644 --- a/command.c +++ b/command.c @@ -1484,7 +1484,7 @@ void keybuffering (int flag) /* Non-blocking check for input character. If - * true, retreive character using kbchar() + * true, retrieve character using kbchar() */ int kbhit(void) { diff --git a/machine.c b/machine.c index bf22c1f..2001a1f 100644 --- a/machine.c +++ b/machine.c @@ -559,6 +559,7 @@ struct hw_class console_class = .reset = null_reset, .read = console_read, .write = console_write, + .update = NULL, }; struct hw_device *console_create (void) diff --git a/main.c b/main.c index afee5ee..e9398ef 100644 --- a/main.c +++ b/main.c @@ -419,14 +419,15 @@ main (int argc, char *argv[]) * here periodically and do the interrupt handling. */ for (cpu_quit = 1; cpu_quit != 0;) { + /* Call each device that needs periodic processing. */ + machine_update (); + if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) { /* Simulate some CPU time, either 1ms worth or up to the next possible IRQ */ total += cpu_execute (mhz * 1024); - /* Call each device that needs periodic processing. */ - machine_update (); } else if ((cycles_per_irq != 0) && (cycles_per_firq == 0)) { diff --git a/miscsbc.c b/miscsbc.c index 6e44b5b..53057d6 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -9,6 +9,8 @@ int smii_i_avail = 1; int smii_o_busy = 0; +// for multicomp09 Rx FIFO +#define CharFIFO_SIZE (8) // for multicomp09 sdmapper: values most-recently written to these registers #define MULTICOMP09_RAMMAX (0x80000) // [NAC HACK 2017Feb01] this does not match RTL!! RTL uses block 7. This is chosen @@ -27,6 +29,16 @@ int mc_addr; int mc_state; int mc_poll; int mc_dindex; +struct CharFIFO { + int wr; + int rd; + int empty; + char data[CharFIFO_SIZE]; +}; + +static struct CharFIFO uart0_rx_fifo = {0,0,1,0}; +unsigned char uart0_wr_status = 0; + // multicomp devices struct hw_device *mc_romdev, *mc_ramdev, *mc_iodev, *mc_consoledev, *mc_sdmapperdev; @@ -200,52 +212,130 @@ struct machine smii_machine = * ********************************************************************/ -/* UART-style console. Console input is blocking (but should not be) +/* UART-style console. + Previously, the input FIFO was not modelled: + Data input is sort-of non-blocking: if you read the UART status + bit and it says RX Char Available, you can read the data register + and know that it will not stall. + However, if you read the data register and no character is + available (rude!) the input will block until you press a key. + Could have it work other than this.. reading the data register + could also call kbhit. When no character is available could + return 0xff or somesuch, which would more accurately model real behaviour. + + Now, the FIFO is modelled and so are UART Rx interrupts: + 1/ each read of status or data calls kbhit and puts a char + (if any) into the FIFO and then: + 1a/ print error message if FIFO overflow + 1b/ for status: char available = FIFO-not-empty + 1c/ for data: if FIFO-not-empty, pop and return oldest char else + print error message (application error) and return 0xff + 2/ register an .update routine for the console_class. The update + routine is called in the exec09 main loop on a periodic basis. + 3/ the update routine calls kbbit and puts a char (if any) into + the FIFO and then: + 3a/ print error message if FIFO overflow + 3b/ if UART interrupt enabled and FIFO-not-empty: call IRQ + 4/ IRQ ISR needs to understand that a UART IRQ arrived rather + than a timer IRQ. TBD how to handle that.. probably by modelling + the timer interrupt in a more complex way.. eg, by testing the mask + *or* by implementing a new mask bit for the UART IRQ. + 5/ on status write of 3 (reset), clear the FIFO. + + The result should work correctly for existing applications: + - polled I/O in FLEX and CamelForth and Cubix and MSBASIC + - timer-driven I/O in FUZIX (and can change FUZIX to allow + rx interrupts, if it does not already) + - lastly, it should allow NitrOS9 L1 to do terminal input + and therefore boot to the command prompt. + offset 0,1 - 1st UART - virtual UART. Main console offset 2,3 - 2nd UART offset 4,5 - 3rd UART offset 6,7 - GPIO unit */ +U8 multicomp_console_rxpoll (void) +{ + unsigned char ch; + if (batch_file) { + // do not allow the batch file to create an overflow + if (uart0_rx_fifo.empty || (uart0_rx_fifo.rd != uart0_rx_fifo.wr)) { + fread( &ch, 1, 1, batch_file); + uart0_rx_fifo.empty = 0; + uart0_rx_fifo.data[uart0_rx_fifo.wr] = ch; + uart0_rx_fifo.wr = (uart0_rx_fifo.wr + 1) % CharFIFO_SIZE; + } + } + else { + if (kbhit()) { + ch = kbchar(); + if ((uart0_rx_fifo.wr == uart0_rx_fifo.rd) && (uart0_rx_fifo.empty == 0)) { + // discard newest char - the real hardware is not polite + // like this! Should really generate a receiver overrun. + printf("[uart0 error: rx FIFO overflow\n"); + } + else { + uart0_rx_fifo.empty = 0; + uart0_rx_fifo.data[uart0_rx_fifo.wr] = ch; + uart0_rx_fifo.wr = (uart0_rx_fifo.wr + 1) % CharFIFO_SIZE; + //printf("[uart0 push char 0x%02d. wr=%d rd=%d empty=%d\n",ch, uart0_rx_fifo.wr, uart0_rx_fifo.rd, uart0_rx_fifo.empty); + } + } + } +} + + U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) { //printf("In console_read with addr=0x%08x pc=0x%04x\n", (unsigned int)addr, get_pc()); unsigned char ch; switch (addr) { - /* UART0 -----------------------------*/ - case 0: /* status */ + + case 0: /* UART0 status */ // b7: interrupt - // b1: can accept TX char - // b0: RX char available - return (batch_file || kbhit()) ? 3 : 2; + // b1: can accept Tx char + // b0: Rx char available + multicomp_console_rxpoll(); + if (uart0_rx_fifo.empty) { + return (uart0_wr_status & 0x80) | 2; + } + else { + return (uart0_wr_status & 0x80) | 3; + } - case 1: /* data */ - if (batch_file && fread( &ch, 1, 1, batch_file)) { + case 1: /* UART0 data */ + multicomp_console_rxpoll(); + if (uart0_rx_fifo.empty) { + printf("[uart0 error: read from EMPTY data register\n"); + return 0xff; } else { - ch = kbchar(); + ch = uart0_rx_fifo.data[uart0_rx_fifo.rd]; + uart0_rx_fifo.rd = (uart0_rx_fifo.rd + 1) % CharFIFO_SIZE; + if (uart0_rx_fifo.rd == uart0_rx_fifo.wr) { + uart0_rx_fifo.empty = 1; + } + // key conversions to make keyboard look DOS-like + if (ch == 127) return 8; // rubout->backspace + if (ch == 10) return 13; // LF->CR + return ch; } - // key conversions to make keyboard look DOS-like - if (ch == 127) return 8; // rubout->backspace - if (ch == 10) return 13; // LF->CR - return ch; - /* UART1 -----------------------------*/ - case 2: /* status */ + case 2: /* UART1 status */ // hardware supports bits [7], [1], [0] printf("[uart1 stat rd addr=0x%08x\n", (unsigned int)addr); return 0x03; - case 3: /* data */ + case 3: /* UART1 data */ printf("[uart1 data rd addr=0x%08x\n", (unsigned int)addr); return 0x42; - /* UART2 -----------------------------*/ - case 4: /* status */ + case 4: /* UART2 status */ // hardware supports bits [7], [1], [0] printf("[uart2 stat rd addr=0x%08x\n", (unsigned int)addr); return 0x03; - case 5: /* data */ + case 5: /* UART2 data */ printf("[uart2 data rd addr=0x%08x\n", (unsigned int)addr); return 0x42; @@ -267,9 +357,13 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va //printf("In console_write with addr=0x%08x val=0x%02x pc=0x%04x\n", (unsigned int)addr, val, get_pc()); //fprintf(log_file,"%02x~%02x\n",(unsigned char)(addr&0xff),val); switch (addr) { - /* UART0 -----------------------------*/ - case 0: /* status */ - if (val==3) { + + case 0: /* UART0 status */ + uart0_wr_status = val; + if (val==3) { /* master reset */ + uart0_rx_fifo.wr=0; + uart0_rx_fifo.wr=0; + uart0_rx_fifo.empty=1; printf("[uart0 reset]"); } else { @@ -277,13 +371,12 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va } break; - case 1: /* data */ - putchar(val); /* UART 1*/ + case 1: /* UART0 data */ + putchar(val); fflush(stdout); break; - /* UART1 -----------------------------*/ - case 2: /* status */ + case 2: /* UART1 status */ if (val==3) { printf("[uart1 reset]"); } @@ -292,12 +385,11 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va } break; - case 3: /* data */ + case 3: /* UART1 data */ printf("[uart1 data wr of 0x%02x\n", val); break; - /* UART2 -----------------------------*/ - case 4: /* status */ + case 4: /* UART2 status */ if (val==3) { printf("[uart2 reset]"); } @@ -306,7 +398,7 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va } break; - case 5: /* data */ + case 5: /* UART2 data */ printf("[uart2 data wr of 0x%02x\n", val); break; @@ -322,6 +414,14 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va } } +void multicomp09_console_update (struct hw_device *dev) +{ + multicomp_console_rxpoll(); + if (uart0_rx_fifo.empty == 0 && (uart0_wr_status & 0x80)) { + request_irq(1); + } +} + // given a physical block number (0-7) return the offset into physical memory int mmu_offset(int blk) { int tmp; @@ -638,8 +738,23 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) } } break; // unreachable - case 5: // TIMER - //fprintf(log_file,"%02x<%02x\n",(unsigned char)(addr&0xff),mc_timer); + case 5: // TIMER read + /* The -I command-line option is used to generate periodic timer interrupts. + If the timer interrupt is enabled, and wot_irqs() indicates that a + timer interrupt is pending, we can flag the interrupt here. + [NAC HACK 2017Mar28] bugette: if the timer interrupt is not + enabled (or, before it is enabled) the ISR will still get + entered and whatever other service routines there will have to cope. + For example, it might get treated as an Rx interrupt, for which + reason the Rx service must check for char available and not simply + assume that entry to the ISR guarantees a char. That's a bit nasty + but the alternative requires binding the request_irq call in main.c + more tightly with the target (could do that with a target call-back) + For now, this bugette should not cause any problems. + */ + if ((mc_timer & 1) && (wot_irqs() & 1)) { + mc_timer |= 0x80; + } return mc_timer; default: // In general, it's an error to read back anything else. However, in the @@ -749,19 +864,19 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) case 4: // SDLBA2 mc_sdlba2 = val; break; - case 5: // TIMER + case 5: // TIMER write // bit [1] is read/write, timer enable - // bit [7] is read, write-1-to-clear + // bit [7] is read, write-1-to-clear, interrupt. // Set this up so that it *always* signals an interrupt // when enabled; when used with the "-I" command-line timer // interrupt feature, this will make it seem as though this // timer is the source of all interrupts. if (val & 2) { - // enabled and signalling interrupt - mc_timer = 0x82; + // timer enabled + mc_timer |= 0x02; } else { - // disabled. Pending interrupt remains or is cleared + // timer disabled. Pending interrupt remains or is cleared // depending upon bit[7] mc_timer = (val & 0x80) ^ 0x80; } @@ -824,8 +939,9 @@ void multicomp09_init (const char *boot_rom_file) /* I/O Devices - UARTs */ mc_consoledev = console_create(); - mc_consoledev->class_ptr->read = multicomp09_console_read; - mc_consoledev->class_ptr->write = multicomp09_console_write; + mc_consoledev->class_ptr->read = multicomp09_console_read; + mc_consoledev->class_ptr->write = multicomp09_console_write; + mc_consoledev->class_ptr->update = multicomp09_console_update; /* I/O Devices - SD controller, MMapper, Timer */ mc_sdmapperdev = sdmapper_create(); From 7745089a3aaf91e915dc6496caa68d7b51c0cadd Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Thu, 30 Mar 2017 23:27:10 +0100 Subject: [PATCH 69/71] Rework interrupt handing in exec09 and the modelling of timer and uart interrupts in the mc09 machine. Scarily clean now! FUZIX and NITROS9 L1 (both of which use timer and UART interrupts) both boot and appear to work correctly. --- 6809.c | 28 +++++++---------- machine.h | 1 + main.c | 49 +++++++++++------------------- miscsbc.c | 89 ++++++++++++++++++++++++++++--------------------------- 4 files changed, 73 insertions(+), 94 deletions(-) diff --git a/6809.c b/6809.c index ddb1cd8..dccd27f 100644 --- a/6809.c +++ b/6809.c @@ -59,16 +59,12 @@ extern int trace_enabled; void irq (void); void firq (void); -/* [NAC HACK 2017Mar28] crude mechanism to allow multicomp09 - to model the timer interrupt +/* Values of 'source' are arbitrary and can be assigned + per-machine. Machine is responsible for using the + corresponding values of 'source' in release_irq. + multicomp09 uses 0 for periodic timer interrupt + 1 for uart0 rx interrupt */ -unsigned int wot_irqs(void) -{ - return irqs_pending; -} - -/* called with source=0 for periodic timer interrupt */ -/* called with source=1 for multicomp09 uart0 rx interrupt */ void request_irq (unsigned int source) { /* If the interrupt is not masked, generate @@ -80,9 +76,11 @@ void request_irq (unsigned int source) irq(); } -/* currently this is never called. Instead, irqs_pending is - always cleared in the ISR. That matches an ISR that processes - to completion +/* IRQ/FIQ are modelled as wire-OR from multiple hw + devices. A machine must call this to model a hw device + negating its contribution to IRQ. + An ISR should be designed to process all sources. If + it does not, the interrupt will re-fire immediately. */ void release_irq (unsigned int source) { @@ -1454,9 +1452,6 @@ void irq (void) irq_start_time = get_cycles(); change_pc(read16(0xfff8)); -#if 1 - irqs_pending = 0; -#endif } void firq (void) @@ -1471,9 +1466,6 @@ void firq (void) EFI |= (I_FLAG | F_FLAG); change_pc(read16(0xfff6)); -#if 1 - firqs_pending = 0; -#endif } void swi (void) diff --git a/machine.h b/machine.h index 037148d..8ced6a2 100644 --- a/machine.h +++ b/machine.h @@ -146,6 +146,7 @@ struct machine void (*dump_thread) (unsigned int thread_id); void (*periodic) (void); void (*dump) (void); + void (*tick) (void); unsigned long cycles_per_sec; }; diff --git a/main.c b/main.c index e9398ef..8ffa5d9 100644 --- a/main.c +++ b/main.c @@ -35,13 +35,11 @@ unsigned long total = 0; /* The frequency of the emulated CPU, in megahertz */ unsigned int mhz = 1; -/* When nonzero, indicates that the IRQ should be triggered periodically, -every so many cycles. By default no periodic IRQ is generated. */ -unsigned int cycles_per_irq = 0; - -/* When nonzero, indicates that the FIRQ should be triggered periodically, -every so many cycles. By default no periodic FIRQ is generated. */ -unsigned int cycles_per_firq = 0; +/* When nonzero, indicates that the machine's tick routine should be + triggered periodically, every so many cycles. Typically this is + used by the machine to generate a timer interrupt. Off By default. +*/ +unsigned int cycles_per_tick = 0; /* Nonzero if debugging support is turned on */ int debug_enabled = 0; @@ -141,8 +139,7 @@ idle_loop (void) if (total_ms_elapsed > 100) { total_ms_elapsed -= 100; - if (machine->periodic) - machine->periodic (); + if (machine->periodic) machine->periodic (); command_periodic (); } @@ -190,10 +187,8 @@ struct option { '-', "68b09", "Emulate the 68B09 variation (2Mhz)" }, { 'R', "realtime", "Limit simulation speed to match realtime", HAS_NEG, NO_ARG, &machine_realtime, 0, NULL, NULL }, - { 'I', "irqfreq", "Asserts an IRQ every so many cycles automatically", - NO_NEG, HAS_ARG, &cycles_per_irq, 0, NULL, NULL }, - { 'F', "firqfreq", "Asserts an FIRQ every so many cycles automatically", - NO_NEG, HAS_ARG, &cycles_per_firq, 0, NULL, NULL }, + { 'I', "tIckfreq", "Automatically calls the machine's tick every so many cycles", + NO_NEG, HAS_ARG, &cycles_per_tick, 0, NULL, NULL }, { 'C', "cycledump", "", HAS_NEG, NO_ARG, &dump_cycles_on_success, 1, NULL, NULL}, { 'o', "os9call", "Treat SWI2 as an OS9/NitrOS9 system call and report postbyte", @@ -414,37 +409,27 @@ main (int argc, char *argv[]) keybuffering (0); /* Now, iterate through the instructions. - * If no IRQs or FIRQs are enabled, we can just call cpu_execute() - * and let it run for a long time; otherwise, we need to come back - * here periodically and do the interrupt handling. */ + Without -I, we can just call cpu_execute() and let it run + for a long time; otherwise, we need to come back here + periodically and call the machine's ->tick() routine */ + //[NAC HACK 2017Mar30] need to schedule this properly instead of this one-or-the-other approach + //.. need to track the rate of each and work out who's next. for (cpu_quit = 1; cpu_quit != 0;) { /* Call each device that needs periodic processing. */ machine_update (); - if ((cycles_per_irq == 0) && (cycles_per_firq == 0)) + if (cycles_per_tick == 0) { /* Simulate some CPU time, either 1ms worth or up to the - next possible IRQ */ + next possible tick */ total += cpu_execute (mhz * 1024); } - else if ((cycles_per_irq != 0) && (cycles_per_firq == 0)) - { - total += cpu_execute (cycles_per_irq); - request_irq (0); - } - else if ((cycles_per_irq == 0) && (cycles_per_firq != 0)) - { - total += cpu_execute (cycles_per_firq); - request_firq (0); - } else { - /* need to track them both and continue to work out which is - next. - */ - sim_error ("Oops. Don't currently support -I and -F together\n"); + total += cpu_execute (cycles_per_tick); + if (machine->tick) machine->tick (); } idle_loop (); diff --git a/miscsbc.c b/miscsbc.c index 53057d6..34616d9 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -36,8 +36,8 @@ struct CharFIFO { char data[CharFIFO_SIZE]; }; -static struct CharFIFO uart0_rx_fifo = {0,0,1,0}; -unsigned char uart0_wr_status = 0; +static struct CharFIFO uart0_rx_fifo; +static unsigned char uart0_wr_status; // multicomp devices struct hw_device *mc_romdev, *mc_ramdev, *mc_iodev, *mc_consoledev, *mc_sdmapperdev; @@ -195,8 +195,7 @@ struct machine smii_machine = { .name = "smii", .fault = fault, - .init = smii_init, - .periodic = 0, + .init = smii_init }; @@ -272,13 +271,12 @@ U8 multicomp_console_rxpoll (void) if ((uart0_rx_fifo.wr == uart0_rx_fifo.rd) && (uart0_rx_fifo.empty == 0)) { // discard newest char - the real hardware is not polite // like this! Should really generate a receiver overrun. - printf("[uart0 error: rx FIFO overflow\n"); + printf("[uart0 error: rx FIFO overflow]\n"); } else { uart0_rx_fifo.empty = 0; uart0_rx_fifo.data[uart0_rx_fifo.wr] = ch; uart0_rx_fifo.wr = (uart0_rx_fifo.wr + 1) % CharFIFO_SIZE; - //printf("[uart0 push char 0x%02d. wr=%d rd=%d empty=%d\n",ch, uart0_rx_fifo.wr, uart0_rx_fifo.rd, uart0_rx_fifo.empty); } } } @@ -306,7 +304,7 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) case 1: /* UART0 data */ multicomp_console_rxpoll(); if (uart0_rx_fifo.empty) { - printf("[uart0 error: read from EMPTY data register\n"); + printf("[uart0 error: read from EMPTY data register]\n"); return 0xff; } else { @@ -314,6 +312,7 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) uart0_rx_fifo.rd = (uart0_rx_fifo.rd + 1) % CharFIFO_SIZE; if (uart0_rx_fifo.rd == uart0_rx_fifo.wr) { uart0_rx_fifo.empty = 1; + release_irq(1); } // key conversions to make keyboard look DOS-like if (ch == 127) return 8; // rubout->backspace @@ -323,20 +322,20 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) case 2: /* UART1 status */ // hardware supports bits [7], [1], [0] - printf("[uart1 stat rd addr=0x%08x\n", (unsigned int)addr); + printf("[uart1 stat rd addr=0x%08x]\n", (unsigned int)addr); return 0x03; case 3: /* UART1 data */ - printf("[uart1 data rd addr=0x%08x\n", (unsigned int)addr); + printf("[uart1 data rd addr=0x%08x]\n", (unsigned int)addr); return 0x42; case 4: /* UART2 status */ // hardware supports bits [7], [1], [0] - printf("[uart2 stat rd addr=0x%08x\n", (unsigned int)addr); + printf("[uart2 stat rd addr=0x%08x]\n", (unsigned int)addr); return 0x03; case 5: /* UART2 data */ - printf("[uart2 data rd addr=0x%08x\n", (unsigned int)addr); + printf("[uart2 data rd addr=0x%08x]\n", (unsigned int)addr); return 0x42; /* GPIO (not modelled) ---------------*/ @@ -364,6 +363,8 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va uart0_rx_fifo.wr=0; uart0_rx_fifo.wr=0; uart0_rx_fifo.empty=1; + uart0_wr_status = 0; + release_irq(1); printf("[uart0 reset]"); } else { @@ -386,7 +387,7 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va break; case 3: /* UART1 data */ - printf("[uart1 data wr of 0x%02x\n", val); + printf("[uart1 data wr of 0x%02x]\n", val); break; case 4: /* UART2 status */ @@ -399,7 +400,7 @@ void multicomp09_console_write (struct hw_device *dev, unsigned long addr, U8 va break; case 5: /* UART2 data */ - printf("[uart2 data wr of 0x%02x\n", val); + printf("[uart2 data wr of 0x%02x]\n", val); break; /* GPIO (not modelled) ---------------*/ @@ -739,22 +740,6 @@ U8 sdmapper_read (struct hw_device *dev, unsigned long addr) } break; // unreachable case 5: // TIMER read - /* The -I command-line option is used to generate periodic timer interrupts. - If the timer interrupt is enabled, and wot_irqs() indicates that a - timer interrupt is pending, we can flag the interrupt here. - [NAC HACK 2017Mar28] bugette: if the timer interrupt is not - enabled (or, before it is enabled) the ISR will still get - entered and whatever other service routines there will have to cope. - For example, it might get treated as an Rx interrupt, for which - reason the Rx service must check for char available and not simply - assume that entry to the ISR guarantees a char. That's a bit nasty - but the alternative requires binding the request_irq call in main.c - more tightly with the target (could do that with a target call-back) - For now, this bugette should not cause any problems. - */ - if ((mc_timer & 1) && (wot_irqs() & 1)) { - mc_timer |= 0x80; - } return mc_timer; default: // In general, it's an error to read back anything else. However, in the @@ -867,19 +852,15 @@ void sdmapper_write (struct hw_device *dev, unsigned long addr, U8 val) case 5: // TIMER write // bit [1] is read/write, timer enable // bit [7] is read, write-1-to-clear, interrupt. - // Set this up so that it *always* signals an interrupt - // when enabled; when used with the "-I" command-line timer - // interrupt feature, this will make it seem as though this - // timer is the source of all interrupts. - if (val & 2) { - // timer enabled - mc_timer |= 0x02; - } - else { - // timer disabled. Pending interrupt remains or is cleared - // depending upon bit[7] - mc_timer = (val & 0x80) ^ 0x80; + + // Enable or disable + mc_timer = (mc_timer & 0xfd) | (val & 2); + + if (val & 0x80) { + release_irq(0); + mc_timer &= 0x7f; } + break; case 6: // MMUADR // ignore writes where bit(4) is set; this is the single-step/nmi control @@ -914,6 +895,20 @@ struct hw_device* sdmapper_create (void) +/* Called periodically when exec09 is invoked with the -I option. + This can be used to model the hardware of a periodic timer and + (for example) invoke IRQ or FIQ as required by the hardware. + For multicomp09, model the timer interrupt: if the timer is enabled, + generate an IRQ. +*/ +void multicomp09_tick (void) +{ + if (mc_timer & 0x02) { + mc_timer |= 0x80; + request_irq(0); + } +} + // [NAC HACK 2015May05] is it legal to have more than one instance of anything? // eg 2 RAMs? I assumed it was but now I realise IT IS NOT! Yeuch. // I assume the same restriction also applies to ROMs and RAMs @@ -963,6 +958,13 @@ void multicomp09_init (const char *boot_rom_file) */ sdmapper_remap(0, 0); + /* Initialise/reset the UART0 input FIFO and its status register*/ + uart0_rx_fifo.wr = 0; + uart0_rx_fifo.rd = 0; + uart0_rx_fifo.empty = 1; + uart0_wr_status = 0; + release_irq(1); + /* If a file multicomp09.bat exists, supply input from it until it's exhausted. */ @@ -1002,8 +1004,8 @@ struct machine multicomp09_machine = .name = "multicomp09", .fault = fault, .init = multicomp09_init, - .periodic = 0, .dump = multicomp09_dump, + .tick = multicomp09_tick }; @@ -1112,6 +1114,5 @@ struct machine kipper1_machine = { .name = "kipper1", .fault = fault, - .init = kipper1_init, - .periodic = 0, + .init = kipper1_init }; From a37962c78d696088a6bdddebb8d9ea53040be925 Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Sat, 1 Apr 2017 20:49:42 +0100 Subject: [PATCH 70/71] UART status register was (wrongly) indicating an Rx interrupt whenever interrupts were enabled, regardless of whether a character was available. Now, only indicate an Rx interrupt when interrupts are enabled AND the Rx FIFO is non-empty. --- miscsbc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/miscsbc.c b/miscsbc.c index 34616d9..7516eac 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -295,7 +295,7 @@ U8 multicomp09_console_read (struct hw_device *dev, unsigned long addr) // b0: Rx char available multicomp_console_rxpoll(); if (uart0_rx_fifo.empty) { - return (uart0_wr_status & 0x80) | 2; + return 2; } else { return (uart0_wr_status & 0x80) | 3; From c8d8eb9ee0f9e93161a5a914d6a0158c26b3b49d Mon Sep 17 00:00:00 2001 From: Neal Crook Date: Wed, 5 Apr 2017 23:43:08 +0100 Subject: [PATCH 71/71] Switch to FRT of 7 to match RTL. --- miscsbc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/miscsbc.c b/miscsbc.c index 7516eac..a2bd08d 100644 --- a/miscsbc.c +++ b/miscsbc.c @@ -13,9 +13,8 @@ int smii_o_busy = 0; #define CharFIFO_SIZE (8) // for multicomp09 sdmapper: values most-recently written to these registers #define MULTICOMP09_RAMMAX (0x80000) -// [NAC HACK 2017Feb01] this does not match RTL!! RTL uses block 7. This is chosen -// for now to match the mapping in NITROS9. -#define FRT_BLOCK (63) +// to match RTL, FRT_BLOCK must be 7 +#define FRT_BLOCK (7) unsigned char mc_mmuadr = 0x00; unsigned char mc_mmufrt = 0x00; // Magic flag for Fixed RAM Top unsigned char mc_mmudat = 0x00;