2009-04-22 Anthony Green <green@moxielogic.com>

* configure.in: Add moxie support.
        * configure: Regenerate.
        * moxie/aclocal.m4, moxie/configure, moxie/configure.in,
        moxie/crt0.S, moxie/fstat.c, moxie/getpid.c, isatty.c,
        moxie/kill.c, moxie/Makefile.in, moxie/moxie-elf-common.ld,
        moxie/print.c, moxie/putnum.c, moxie/qemu.ld, moxie/qemu-time.c,
        moxie/qemu-write.c, moxie/sbrk.c, moxie/sim-close.S,
        moxie/sim-exit.S,
        moxie/sim-inbyte.c, moxie/sim.ld, moxie/sim-lseek.c,
        moxie/sim-lseek.S, moxie/sim-open.S, moxie/sim-read.S, moxie/sim-time.c,
        moxie/sim-unlink.S, moxie/sim-write.S, moxie/stat.c: New files.
This commit is contained in:
Jeff Johnston 2009-04-22 19:48:07 +00:00
parent 96baa3e74a
commit bc6b90cc10
31 changed files with 6435 additions and 2445 deletions

View File

@ -1,3 +1,17 @@
2009-04-22 Anthony Green <green@moxielogic.com>
* configure.in: Add moxie support.
* configure: Regenerate.
* moxie/aclocal.m4, moxie/configure, moxie/configure.in,
moxie/crt0.S, moxie/fstat.c, moxie/getpid.c, isatty.c,
moxie/kill.c, moxie/Makefile.in, moxie/moxie-elf-common.ld,
moxie/print.c, moxie/putnum.c, moxie/qemu.ld, moxie/qemu-time.c,
moxie/qemu-write.c, moxie/sbrk.c, moxie/sim-close.S,
moxie/sim-exit.S,
moxie/sim-inbyte.c, moxie/sim.ld, moxie/sim-lseek.c,
moxie/sim-lseek.S, moxie/sim-open.S, moxie/sim-read.S, moxie/sim-time.c,
moxie/sim-unlink.S, moxie/sim-write.S, moxie/stat.c: New files.
2009-04-22 DJ Delorie <dj@redhat.com>
* mep/sim-crt0.S (_start): Fix typo.

4116
libgloss/configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -112,6 +112,10 @@ case "${target}" in
AC_CONFIG_SUBDIRS(mep)
config_testsuite = true;
;;
moxie-*-*)
AC_CONFIG_SUBDIRS(moxie)
config_testsuite=true
;;
mt-*-*)
AC_CONFIG_SUBDIRS(mt)
config_testsuite=true

147
libgloss/moxie/Makefile.in Normal file
View File

@ -0,0 +1,147 @@
# Copyright (c) 2008 Anthony Green
#
# The authors hereby grant permission to use, copy, modify, distribute,
# and license this software and its documentation for any purpose, provided
# that existing copyright notices are retained in all copies and that this
# notice is included verbatim in any distributions. No written agreement,
# license, or royalty fee is required for any of the authorized uses.
# Modifications to this software may be copyrighted by their authors
# and need not follow the licensing terms described here, provided that
# the new terms are clearly indicated on the first page of each file where
# they apply.
# Makefile for libgloss/spro. This is the board support code for the
# moxie target.
DESTDIR =
VPATH = @srcdir@ @srcdir@/..
srcdir = @srcdir@
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
prefix = @prefix@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
target_alias = @target_alias@
bindir = @bindir@
libdir = @libdir@
tooldir = $(exec_prefix)/$(target_alias)
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTIDIRS =
MULTISUBDIR =
MULTIDO = true
MULTICLEAN = true
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
SHELL = /bin/sh
CC = @CC@
AS = @AS@
AR = @AR@
LD = @LD@
RANLIB = @RANLIB@
AR_FLAGS = rc
OBJDUMP = `if [ -f ${objroot}/../binutils/objdump ] ; \
then echo ${objroot}/../binutils/objdump ; \
else t='$(program_transform_name)'; echo objdump | sed -e $$t ; fi`
OBJCOPY = `if [ -f ${objroot}/../binutils/objcopy ] ; \
then echo ${objroot}/../binutils/objcopy ; \
else t='$(program_transform_name)'; echo objcopy | sed -e $$t ; fi`
LD_SCRIPTS = moxie-elf-common.ld qemu.ld sim.ld
CRT0 = crt0.o
SIM_BSP = libsim.a
SIM_OBJS = fstat.o \
getpid.o \
isatty.o \
kill.o \
putnum.o \
sbrk.o \
sim-close.o \
sim-exit.o \
sim-inbyte.o \
sim-lseek.o \
sim-open.o \
sim-read.o \
sim-time.o \
sim-unlink.o \
sim-write.o \
stat.o
QEMU_BSP = libqemu.a
QEMU_OBJS = qemu-write.o \
qemu-time.o \
sim-exit.o \
sbrk.o \
sim-close.o \
fstat.o \
isatty.o \
sim-lseek.o \
sim-read.o
#### Host specific Makefile fragment comes in here.
@host_makefile_frag@
all: $(CRT0) $(SIM_BSP) $(QEMU_BSP)
$(SIM_BSP): $(SIM_OBJS)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
$(QEMU_BSP): $(QEMU_OBJS)
$(AR) $(ARFLAGS) $@ $?
$(RANLIB) $@
fstat.o: $(srcdir)/fstat.c
getpid.o: $(srcdir)/getpid.c
isatty.o: $(srcdir)/isatty.c
kill.o: $(srcdir)/kill.c
putnum.o: $(srcdir)/putnum.c
sbrk.o: $(srcdir)/sbrk.c
sim-close.o: $(srcdir)/sim-close.S
sim-exit.o: $(srcdir)/sim-exit.S
sim-inbyte.o: $(srcdir)/sim-inbyte.c
sim-lseek.o: $(srcdir)/sim-lseek.c
sim-open.o: $(srcdir)/sim-open.S
sim-read.o: $(srcdir)/sim-read.S
sim-time.o: $(srcdir)/sim-time.c
sim-unlink.o: $(srcdir)/sim-unlink.S
sim-write.o: $(srcdir)/sim-write.S
stat.o: $(srcdir)/stat.c
qemu-write.o: $(srcdir)/qemu-write.c
install: $($(CPU)_INSTALL)
$(INSTALL_DATA) $(CRT0) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(CRT0)
$(INSTALL_DATA) $(SIM_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(SIM_BSP)
$(INSTALL_DATA) $(QEMU_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(QEMU_BSP)
for x in ${LD_SCRIPTS}; do \
${INSTALL_DATA} ${srcdir}/$$x $(DESTDIR)${tooldir}/lib/$$x; \
done;
clean mostlyclean:
rm -f *.o *.a
distclean maintainer-clean realclean: clean
rm -f Makefile config.cache config.log config.status
.PHONY: info dvi doc install-info clean-info
info doc dvi:
install-info:
clean-info:
Makefile: Makefile.in config.status @host_makefile_frag_path@
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck

344
libgloss/moxie/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,344 @@
# generated automatically by aclocal 1.9.5 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 7
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])
AC_SUBST([$1_FALSE])
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 8
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
case $depmode in
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
none) break ;;
esac
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this.
if depmode=$depmode \
source=sub/conftest.c object=sub/conftest.${OBJEXT-o} \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c -o sub/conftest.${OBJEXT-o} sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftest.${OBJEXT-o} sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 3
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[for mf in $CONFIG_FILES; do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# So let's grep whole file.
if grep '^#.*generated by automake' $mf > /dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 3
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo done
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# We grep out `Entering directory' and `Leaving directory'
# messages which can occur if `w' ends up in MAKEFLAGS.
# In particular we don't look at `^make:' because GNU make might
# be invoked under some other name (usually "gmake"), in which
# case it prints its new name instead of `make'.
if test "`$am_make -s -f confmf 2> /dev/null | grep -v 'ing directory'`" = "done"; then
am__include=include
am__quote=
_am_result=GNU
fi
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
if test "`$am_make -s -f confmf 2> /dev/null`" = "done"; then
am__include=.include
am__quote="\""
_am_result=BSD
fi
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
m4_include([../acinclude.m4])

3136
libgloss/moxie/configure vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,55 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.59)
AC_INIT(crt0.S)
if test "${enable_shared}" = "yes" ; then
echo "Shared libraries not supported for cross compiling, ignored"
fi
if test "$srcdir" = "." ; then
if test "${with_target_subdir}" != "." ; then
libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
else
libgloss_topdir="${srcdir}/${with_multisrctop}../.."
fi
else
libgloss_topdir="${srcdir}/../.."
fi
AC_CONFIG_AUX_DIR($libgloss_topdir)
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
AC_PROG_INSTALL
LIB_AC_PROG_CC
AS=${AS-as}
AC_SUBST(AS)
AR=${AR-ar}
AC_SUBST(AR)
LD=${LD-ld}
AC_SUBST(LD)
AC_PROG_RANLIB
LIB_AM_PROG_AS
host_makefile_frag=${srcdir}/../config/default.mh
dnl We have to assign the same value to other variables because autoconf
dnl doesn't provide a mechanism to substitute a replacement keyword with
dnl arbitrary data or pathnames.
dnl
host_makefile_frag_path=$host_makefile_frag
AC_SUBST(host_makefile_frag_path)
AC_SUBST_FILE(host_makefile_frag)
AC_CONFIG_FILES(Makefile,
. ${libgloss_topdir}/config-ml.in,
srcdir=${srcdir}
target=${target}
with_multisubdir=${with_multisubdir}
ac_configure_args="${ac_configure_args} --enable-multilib"
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
libgloss_topdir=${libgloss_topdir}
)
AC_OUTPUT

40
libgloss/moxie/crt0.S Normal file
View File

@ -0,0 +1,40 @@
/* crt0.S -- startup file for moxie
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
.globl __start
.weak _start
.text
.type __start,@function
__start:
_start:
ldi.l $sp, _stack /* load up stack pointer */
ldi.l $fp, 0x0 /* zero fp to allow unwinders to stop */
/* zero the bss area */
/* TODO */
/* call memset */
/* Call _init to invoke static constructors, etc. */
jsra _init
/* Set argc and argv. These are populated by the simulator. */
lda.l $r0, 0x4
ldi.l $r1, 0x8
jsra main
jsra exit
.Lend:
.size __start,(.Lend-__start)

30
libgloss/moxie/fstat.c Normal file
View File

@ -0,0 +1,30 @@
/* fstat.c -- get status of a file.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <sys/stat.h>
#include "glue.h"
/*
* fstat -- Since we have no file system, we just return an error.
*/
int
_DEFUN (_fstat, (fd, buf),
int fd _AND
struct stat *buf)
{
buf->st_mode = S_IFCHR; /* Always pretend to be a tty */
buf->st_blksize = 0;
return (0);
}

25
libgloss/moxie/getpid.c Normal file
View File

@ -0,0 +1,25 @@
/* getpid.c -- get the current process id.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "glue.h"
/*
* getpid -- only one process, so just return 1.
*/
int
_DEFUN (_getpid, (),
)
{
return __MYPID;
}

27
libgloss/moxie/isatty.c Normal file
View File

@ -0,0 +1,27 @@
/* isatty.c -- chek the terminal device.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "glue.h"
/*
* isatty -- returns 1 if connected to a terminal device,
* returns 0 if not. Since we're hooked up to a
* serial port, we'll say yes _AND return a 1.
*/
int
_DEFUN (_isatty, (fd),
int fd)
{
return (1);
}

30
libgloss/moxie/kill.c Normal file
View File

@ -0,0 +1,30 @@
/* kill.c -- remove a process.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "glue.h"
extern void _exit (int) __attribute__((__noreturn__));
/*
* kill -- go out via exit...
*/
int
_DEFUN (_kill, (pid, sig),
int pid _AND
int sig)
{
if(pid == __MYPID)
_exit(sig);
return 0;
}

View File

@ -0,0 +1,234 @@
/*
* The common part of the default linker scripts for standalone
* executables running on a Moxie processor.
*
* Copyright (C) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify,
* distribute, and license this software and its documentation for any
* purpose, provided that existing copyright notices are retained in
* all copies and that this notice is included verbatim in any
* distributions. No written agreement, license, or royalty fee is
* required for any of the authorized uses. Modifications to this
* software may be copyrighted by their authors and need not follow
* the licensing terms described here, provided that the new terms are
* clearly indicated on the first page of each file where they apply.
*/
OUTPUT_FORMAT("elf32-moxie")
OUTPUT_ARCH(moxie)
ENTRY(_start)
SECTIONS
{
/* Read-only sections, merged into text segment: */
. = 0x00001000;
.interp : { *(.interp) }
.hash : { *(.hash) }
.dynsym : { *(.dynsym) }
.dynstr : { *(.dynstr) }
.gnu.version : { *(.gnu.version) }
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }
.rel.init : { *(.rel.init) }
.rela.init : { *(.rela.init) }
.rel.text :
{
*(.rel.text)
*(.rel.text.*)
*(.rel.gnu.linkonce.t*)
}
.rela.text :
{
*(.rela.text)
*(.rela.text.*)
*(.rela.gnu.linkonce.t*)
}
.rel.fini : { *(.rel.fini) }
.rela.fini : { *(.rela.fini) }
.rel.rodata :
{
*(.rel.rodata)
*(.rel.rodata.*)
*(.rel.gnu.linkonce.r*)
}
.rela.rodata :
{
*(.rela.rodata)
*(.rela.rodata.*)
*(.rela.gnu.linkonce.r*)
}
.rel.data :
{
*(.rel.data)
*(.rel.data.*)
*(.rel.gnu.linkonce.d*)
}
.rela.data :
{
*(.rela.data)
*(.rela.data.*)
*(.rela.gnu.linkonce.d*)
}
.rel.ctors : { *(.rel.ctors) }
.rela.ctors : { *(.rela.ctors) }
.rel.dtors : { *(.rel.dtors) }
.rela.dtors : { *(.rela.dtors) }
.rel.got : { *(.rel.got) }
.rela.got : { *(.rela.got) }
.rel.sdata :
{
*(.rel.sdata)
*(.rel.sdata.*)
*(.rel.gnu.linkonce.s*)
}
.rela.sdata :
{
*(.rela.sdata)
*(.rela.sdata.*)
*(.rela.gnu.linkonce.s*)
}
.rel.sbss : { *(.rel.sbss) }
.rela.sbss : { *(.rela.sbss) }
.rel.bss : { *(.rel.bss) }
.rela.bss : { *(.rela.bss) }
.rel.plt : { *(.rel.plt) }
.rela.plt : { *(.rela.plt) }
.plt : { *(.plt) }
.text :
{
*(.text)
*(.text.*)
*(.stub)
/* .gnu.warning sections are handled specially by elf32.em. */
*(.gnu.warning)
*(.gnu.linkonce.t*)
*(.glue_7t) *(.glue_7)
} =0
.init :
{
KEEP (*(.init))
} =0
_etext = .;
PROVIDE (etext = .);
.fini :
{
KEEP (*(.fini))
} =0
.rodata : { *(.rodata) *(.rodata.*) *(.gnu.linkonce.r*) }
.rodata1 : { *(.rodata1) }
.eh_frame_hdr : { *(.eh_frame_hdr) }
/* Adjust the address for the data segment. We want to adjust up to
the same address within the page on the next page up. */
. = ALIGN(256) + (. & (256 - 1));
.data :
{
*(.data)
*(.data.*)
*(.gnu.linkonce.d*)
SORT(CONSTRUCTORS)
}
.data1 : { *(.data1) }
.eh_frame : { KEEP (*(.eh_frame)) }
.gcc_except_table : { *(.gcc_except_table) }
.ctors :
{
/* gcc uses crtbegin.o to find the start of
the constructors, so we make sure it is
first. Because this is a wildcard, it
doesn't matter if the user does not
actually link against crtbegin.o; the
linker won't look for a file to match a
wildcard. The wildcard also means that it
doesn't matter which directory crtbegin.o
is in. */
KEEP (*crtbegin.o(.ctors))
/* We don't want to include the .ctor section from
from the crtend.o file until after the sorted ctors.
The .ctor section from the crtend file contains the
end of ctors marker and it must be last */
KEEP (*(EXCLUDE_FILE (*crtend.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
}
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
}
.jcr : { KEEP (*(.jcr)) }
.got : { *(.got.plt) *(.got) }
.dynamic : { *(.dynamic) }
/* We want the small data sections together, so single-instruction offsets
can access them all, and initialized data all before uninitialized, so
we can shorten the on-disk segment size. */
.sdata :
{
*(.sdata)
*(.sdata.*)
*(.gnu.linkonce.s.*)
}
_edata = .;
PROVIDE (edata = .);
__bss_start = .;
__bss_start__ = .;
.sbss :
{
*(.dynsbss)
*(.sbss)
*(.sbss.*)
*(.scommon)
}
.bss :
{
*(.dynbss)
*(.bss)
*(.bss.*)
*(COMMON)
/* Align here to ensure that the .bss section occupies space up to
_end. Align after .bss to ensure correct alignment even if the
.bss section disappears because there are no input sections. */
. = ALIGN(32 / 8);
}
. = ALIGN(32 / 8);
_end = .;
_bss_end__ = . ; __bss_end__ = . ; __end__ = . ;
PROVIDE (end = .);
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
/* DWARF debug sections.
Symbols in the DWARF debugging sections are relative to the beginning
of the section so we begin them at 0. */
/* DWARF 1 */
.debug 0 : { *(.debug) }
.line 0 : { *(.line) }
/* GNU DWARF 1 extensions */
.debug_srcinfo 0 : { *(.debug_srcinfo) }
.debug_sfnames 0 : { *(.debug_sfnames) }
/* DWARF 1.1 and DWARF 2 */
.debug_aranges 0 : { *(.debug_aranges) }
.debug_pubnames 0 : { *(.debug_pubnames) }
/* DWARF 2 */
.debug_info 0 : { *(.debug_info) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_line 0 : { *(.debug_line) }
.debug_frame 0 : { *(.debug_frame) }
.debug_str 0 : { *(.debug_str) }
.debug_loc 0 : { *(.debug_loc) }
.debug_macinfo 0 : { *(.debug_macinfo) }
.debug_ranges 0 : { *(.debug_ranges) }
/* SGI/MIPS DWARF 2 extensions */
.debug_weaknames 0 : { *(.debug_weaknames) }
.debug_funcnames 0 : { *(.debug_funcnames) }
.debug_typenames 0 : { *(.debug_typenames) }
.debug_varnames 0 : { *(.debug_varnames) }
.stack 0x80000 : { _stack = .; *(.stack) }
/* These must appear regardless of . */
}

27
libgloss/moxie/print.c Normal file
View File

@ -0,0 +1,27 @@
/* print.c -- print a string on the output device.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "glue.h"
/*
* print -- do a raw print of a string
*/
void
_DEFUN (_print, (ptr),
char *ptr)
{
while (*ptr) {
outbyte (*ptr++);
}
}

41
libgloss/moxie/putnum.c Normal file
View File

@ -0,0 +1,41 @@
/* putnum.c -- put a hex number on the output device.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "glue.h"
/*
* putnum -- print a 32 bit number in hex
*/
void
_DEFUN (_putnum, (num),
unsigned int num)
{
char buf[9];
int cnt;
char *ptr;
int digit;
ptr = buf;
for (cnt = 7 ; cnt >= 0 ; cnt--) {
digit = (num >> (cnt * 4)) & 0xf;
if (digit <= 9)
*ptr++ = (char) ('0' + digit);
else
*ptr++ = (char) ('a' - 10 + digit);
}
*ptr = (char) 0;
print (buf);
}

116
libgloss/moxie/qemu-time.c Normal file
View File

@ -0,0 +1,116 @@
/* qemu-time.c -- stubs so clock can be linked in.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <errno.h>
#include <time.h>
#include <sys/time.h>
#include <sys/times.h>
#include "glue.h"
/* This is the base address of the mc146818 RTC i/o port. */
#define RTC_PORT 0x400
#define RTC_SECONDS 0x00
#define RTC_SECONDS_ALARM 0x01
#define RTC_MINUTES 0x02
#define RTC_MINUTES_ALARM 0x03
#define RTC_HOURS 0x04
#define RTC_HOURS_ALARM 0x05
#define RTC_DAY_OF_WEEK 0x06
#define RTC_DATE_OF_MONTH 0x07
#define RTC_MONTH 0x08
#define RTC_YEAR 0x09
#define RTC_CONFIG_A 0x0A
#define RTC_CONFIG_B 0x0B
#define RTC_CONFIG_C 0x0C
#define RTC_CONFIG_D 0x0D
/*
* _times -- FIXME
*/
int
_DEFUN (_times, _times (buf),
struct tms *buf)
{
errno = EINVAL;
return (-1);
}
/* Read a value from the RTC port. */
static unsigned char
rtc_read (unsigned char reg)
{
*(volatile unsigned char *)(RTC_PORT) = reg;
return *(volatile unsigned char *)(RTC_PORT + 1);
}
/* Write a value to the RTC port. */
static void
rtc_write (unsigned char reg, unsigned char val)
{
*(volatile unsigned char *)(RTC_PORT) = reg;
*(volatile unsigned char *)(RTC_PORT + 1) = val;
}
/* Convert BCD to Decimal. */
#define BCD2DEC(BYTE) ((((BYTE >> 4) & 0xF) * 10) + (BYTE & 0xF))
/*
* time -- return current time in seconds.
*/
time_t
_DEFUN (time, time (t),
time_t *t)
{
struct tm tm;
time_t ret;
tm.tm_sec = BCD2DEC(rtc_read(RTC_SECONDS));
tm.tm_min = BCD2DEC(rtc_read(RTC_MINUTES));
tm.tm_hour = BCD2DEC(rtc_read(RTC_HOURS));
tm.tm_wday = BCD2DEC(rtc_read(RTC_DAY_OF_WEEK)) - 1;
tm.tm_mday = BCD2DEC(rtc_read(RTC_DATE_OF_MONTH));
tm.tm_mon = BCD2DEC(rtc_read(RTC_MONTH)) - 1;
tm.tm_year = BCD2DEC(rtc_read(RTC_YEAR)) + 100;
/* FIXME. Not really sure how to handle this. */
tm.tm_isdst = 1;
ret = mktime(&tm);
if (t)
*t = ret;
return ret;
}
/*
* _gettimeofday -- implement in terms of time, which means we can't
* return the microseconds.
*/
int
_DEFUN (_gettimeofday, _gettimeofday (tv, tz),
struct timeval *tv _AND
void *tzvp)
{
struct timezone *tz = tzvp;
struct tm tm;
if (tz)
tz->tz_minuteswest = tz->tz_dsttime = 0;
tv->tv_usec = 0;
tv->tv_sec = time(0);
return 0;
}

View File

@ -0,0 +1,23 @@
/*
* qemu-write.c -- write interface for default qemu simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
int _write (int fd, char *buf, int len)
{
int i = 0;
while (i < len)
*(char *)0x3f8 = buf[i++];
return len;
}

2
libgloss/moxie/qemu.ld Normal file
View File

@ -0,0 +1,2 @@
GROUP(-lc -lgcc -lqemu)
INCLUDE moxie-elf-common.ld

54
libgloss/moxie/sbrk.c Normal file
View File

@ -0,0 +1,54 @@
/* sbrk.c -- allocate memory dynamically.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <errno.h>
#include "glue.h"
/* just in case, most boards have at least some memory */
#ifndef RAMSIZE
# define RAMSIZE (caddr_t)0x100000
#endif
char *__heap_ptr = (char *)&_end;
/*
* sbrk -- changes heap size size. Get nbytes more
* RAM. We just increment a pointer in what's
* left of memory on the board.
*/
char *
_sbrk (nbytes)
int nbytes;
{
char *base;
char *sp;
base = __heap_ptr;
__heap_ptr += nbytes;
return base;
/* FIXME: We really want to make sure we don't run out of RAM, but this
* isn't very portable.
*/
#if 0
if ((RAMSIZE - heap_ptr - nbytes) >= 0) {
base = heap_ptr;
heap_ptr += nbytes;
return (base);
} else {
errno = ENOMEM;
return ((char *)-1);
}
#endif
}

View File

@ -0,0 +1,37 @@
/*
* sim-close.S -- close interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "syscall.h"
/*
* Input:
* $r0 -- File descriptor to close.
*
* Output:
* $r0 -- 0 or -1.
* errno -- Set if an error
*/
.globl _close
.type _close,@function
.weak close
.text
_close:
close:
swi SYS_close
ret
.Lend:
.size _close,.Lend-_close

33
libgloss/moxie/sim-exit.S Normal file
View File

@ -0,0 +1,33 @@
/*
* sim-exit.S -- _exit interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "syscall.h"
/*
* Input:
* $r0 -- exit value
*
* Output:
* none
*/
.globl _exit
.type _exit,@function
.text
_exit:
swi SYS_exit
.Lend:
.size _exit,.Lend-_exit

View File

@ -0,0 +1,26 @@
/*
* sim-inbyte.c -- read a character from standard input.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
int
inbyte ()
{
char c;
if (read (0, &c, 1) <= 0)
return -1;
return c;
}

View File

@ -0,0 +1,32 @@
/*
* sim-lseek.S -- write interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <sys/types.h>
#include <errno.h>
/*
* lseek -- Since a simulated serial port is non-seekable, we return
* an error.
*/
off_t
_DEFUN (_lseek, (fd, offset, whence),
int fd _AND
off_t offset _AND
int whence)
{
errno = ESPIPE;
return ((off_t)-1);
}

View File

@ -0,0 +1,32 @@
/*
* sim-lseek.S -- write interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <sys/types.h>
#include <errno.h>
/*
* lseek -- Since a simulated serial port is non-seekable, we return
* an error.
*/
off_t
_DEFUN (_lseek, (fd, offset, whence),
int fd _AND
off_t offset _AND
int whence)
{
/* errno = ESPIPE; */
return ((off_t)-1);
}

39
libgloss/moxie/sim-open.S Normal file
View File

@ -0,0 +1,39 @@
/*
* sim-open.S -- open interface for frv simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "syscall.h"
/*
* Input:
* $r0 -- File name to open.
* $r1 -- open mode.
* -0x12($fp) -- optionally, the permission bits to set the file to.
*
* Output:
* $r0 -- file descriptor or -1.
* errno -- Set if an error
*/
.globl _open
.type _open,@function
.weak open
.text
_open:
open:
swi SYS_open
ret
.Lend:
.size _open,.Lend-_open

39
libgloss/moxie/sim-read.S Normal file
View File

@ -0,0 +1,39 @@
/*
* sim-read.S -- read interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "syscall.h"
/*
* Input:
* $r0 -- File descriptor.
* $r1 -- Buffer to be read into.
* -0x12($fp) -- Length of the buffer.
*
* Output:
* $r0 -- Length read or -1.
* errno -- Set if an error
*/
.globl _read
.type _read,@function
.weak read
.text
_read:
read:
swi SYS_read
ret
.Lend:
.size _read,.Lend-_read

78
libgloss/moxie/sim-time.c Normal file
View File

@ -0,0 +1,78 @@
/* sim-time.c -- stubs so clock can be linked in.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <errno.h>
#include <sys/time.h>
#include <sys/times.h>
#include "glue.h"
/*
* time -- simulator interface to return current time in seconds.
*/
__asm__ ("\
.text\n\
.globl _sim_time\n\
.type _sim_time,@function\n\
_sim_time:\n\
bad\n \
ret\n\
.Lsim:\n\
.size _sim_time,.Lsim-_sim_time");
extern time_t _sim_time (void) __asm__("_sim_time");
/*
* time -- return current time in seconds.
*/
time_t
_DEFUN (time, time (t),
time_t *t)
{
time_t ret = _sim_time ();
if (t)
*t = ret;
return ret;
}
/*
* _times -- no clock, so return an error.
*/
int
_DEFUN (_times, _times (buf),
struct tms *buf)
{
errno = EINVAL;
return (-1);
}
/*
* _gettimeofday -- implement in terms of time, which means we can't return the
* microseconds.
*/
int
_DEFUN (_gettimeofday, _gettimeofday (tv, tz),
struct timeval *tv _AND
void *tzvp)
{
struct timezone *tz = tzvp;
if (tz)
tz->tz_minuteswest = tz->tz_dsttime = 0;
tv->tv_usec = 0;
tv->tv_sec = _sim_time ();
return 0;
}

View File

@ -0,0 +1,28 @@
/*
* sim-unlink.S -- write interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "syscall.h"
.globl _unlink
.type _unlink,@function
.weak unlink
.text
_unlink:
unlink:
bad
ret
.Lend:
.size _unlink,.Lend-_unlink

View File

@ -0,0 +1,39 @@
/*
* sim-write.S -- write interface for moxie simulator
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include "syscall.h"
/*
* Input:
* $r0 -- File descriptor.
* $r1 -- String to be printed.
* -0x12($fp) -- Length of the string.
*
* Output:
* $r0 -- Length written or -1.
* errno -- Set if an error
*/
.globl _write
.type _write,@function
.weak write
.text
_write:
write:
swi SYS_write
ret
.Lend:
.size _write,.Lend-_write

2
libgloss/moxie/sim.ld Normal file
View File

@ -0,0 +1,2 @@
GROUP(-lc -lgcc -lsim)
INCLUDE moxie-elf-common.ld

30
libgloss/moxie/stat.c Normal file
View File

@ -0,0 +1,30 @@
/* stat.c -- Get the status of a file.
*
* Copyright (c) 2008 Anthony Green
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <sys/stat.h>
#include <errno.h>
#include "glue.h"
/*
* stat -- Since we have no file system, we just return an error.
*/
int
_DEFUN (_stat, (path, buf),
const char *path _AND
struct stat *buf)
{
errno = EIO;
return (-1);
}