2012-02-21 Jeremy Bennett <jeremy.bennett@embecosm.com>

Alan Lehotsky  <apl@alum.mit.edu>
            Joern Rennecke  <joern.rennecke@embecosm.com>

        * configure.in: Add Epiphany support.
        * configure: Regenerate.
        * epiphany: New directory.
        * libgloss/README: Add Epiphany entry.
This commit is contained in:
Jeff Johnston 2012-02-21 22:37:47 +00:00
parent 9edde1d2c4
commit b07cfbff06
36 changed files with 6728 additions and 0 deletions

View File

@ -1,3 +1,12 @@
2012-02-21 Jeremy Bennett <jeremy.bennett@embecosm.com>
Alan Lehotsky <apl@alum.mit.edu>
Joern Rennecke <joern.rennecke@embecosm.com>
* configure.in: Add Epiphany support.
* configure: Regenerate.
* epiphany: New directory.
* libgloss/README: Add Epiphany entry.
2012-01-23 Stuart Henderson <stuart.henderson@analog.com>
* bfin/_exit.c: New file.

View File

@ -7,3 +7,4 @@ mep - Toshiba Media Processor.
pa - WinBond and Oki boards with a PA.
mips - R3000 support. Array Tech LSI33k based RAID disk controller.
lm32 - Lattice Mico32 simulator.
epiphany - Adapteva Epiphany multicore processor.

6
libgloss/configure vendored
View File

@ -665,6 +665,7 @@ target_alias
CCAS
CCASFLAGS'
ac_subdirs_all='doc
epiphany
i386
m32r
m68hc11
@ -2390,6 +2391,11 @@ config_testsuite=true
config_libnosys=true
case "${target}" in
epiphany-*-*)
subdirs="$subdirs epiphany"
config_testsuite=true
;;
i[3456]86-*-elf* | i[3456]86-*-coff*)
subdirs="$subdirs i386"

View File

@ -34,6 +34,10 @@ dnl indicates whether to run configure within the libnosys subdirectory
config_libnosys=true
case "${target}" in
epiphany-*-*)
AC_CONFIG_SUBDIRS(epiphany)
config_testsuite=true
;;
i[[3456]]86-*-elf* | i[[3456]]86-*-coff*)
AC_CONFIG_SUBDIRS([i386])
;;

View File

@ -0,0 +1,197 @@
# Makefile for libgloss/epiphany
# Copyright (c) 2011, 2012 Adapteva, Inc.
# All rights reserved.
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Adapteva nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
# Standard proforma copied from libnosys
DESTDIR =
VPATH = @srcdir@
srcdir = @srcdir@
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
prefix = @prefix@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
target_alias = @target_alias@
program_transform_name = @program_transform_name@
bindir = @bindir@
libdir = @libdir@
tooldir = $(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@
AS = `if [ -f ${objroot}/../gas/as-new ] ; \
then echo ${objroot}/../gas/as-new ; \
else echo as ; fi`
AR = @AR@
#LD = @LD@
LD = `if [ -f ${objroot}/../ld/ld-new ] ; \
then echo ${objroot}/../ld/ld-new ; \
else echo ld ; fi`
RANLIB = @RANLIB@
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`
GCC_LDFLAGS = `if [ -d ${objroot}/../gcc ] ; \
then echo -L${objroot}/../gcc ; fi`
NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi`
NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi`
INCLUDES = -I. -I$(srcdir)/.. -I$(srcdir)/../../newlib/libc/machine/epiphany
# Note that when building the library, ${MULTILIB} is not the way multilib
# options are passed; they're passed in $(CFLAGS).
CFLAGS_FOR_TARGET = ${MULTILIB} ${INCLUDES} ${NEWLIB_CFLAGS}
LDFLAGS_FOR_TARGET = ${MULTILIB} ${NEWLIB_LDFLAGS}
AR_FLAGS = qc
.c.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.C.o:
$(CC) $(CFLAGS_FOR_TARGET) -O2 $(INCLUDES) -c $(CFLAGS) $<
.S.o:
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) -c $(CFLAGS) $<
.s.o:
$(AS) $(ASFLAGS_FOR_TARGET) $(INCLUDES) $(ASFLAGS) -o $*.o $<
#
# GCC knows to run the preprocessor on .S files before it assembles them.
#
.S.o:
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $<
#
# this is a bogus target that'll produce an assembler from the
# C source with the right compiler options. this is so we can
# track down code generation or debug symbol bugs.
#
.c.s:
$(CC) $(CFLAGS_FOR_TARGET) -S $(INCLUDES) $(CFLAGS) $<
# EPIPHANY specific stuff
# Object files needed for all libraries
COMMON_OBJS = access.o \
close.o \
environ.o \
execve.o \
fork.o \
fstat.o \
getpid.o \
gettimeofday.o \
_isatty.o \
kill.o \
link.o \
lseek.o \
open.o \
read.o \
sbrk.o \
stat.o \
times.o \
unlink.o \
wait.o \
write.o \
_exit.o \
epiphany-syscalls.o \
epiphany-ivthandlers.o
UNUSED_OBJS = chown.o \
errno.o \
gettod.o \
readlink.o \
symlink.o
# Object files specific to particular targets.
SIMOBJS = $(COMMON_OBJS)
OUTPUTS = libepiphany.a crt0.o
all: $(OUTPUTS)
#
# here's where we build the library for each target
#
libepiphany.a: $(SIMOBJS)
${AR} ${ARFLAGS} $@ $(SIMOBJS)
${RANLIB} $@
_exit.o: _exit.S
$(CC) $(CFLAGS_FOR_TARGET) $(INCLUDES) $(CFLAGS) -c $<
doc:
clean mostlyclean:
rm -f $(OUTPUTS) *.i *~ *.o *-test *.srec *.dis *.map *.x
distclean maintainer-clean realclean: clean
rm -f Makefile config.status $(OUTPUTS)
.PHONY: install info install-info clean-info
install:
@for outputs in ${OUTPUTS}; do\
mkdir -p $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
$(INSTALL_PROGRAM) $${outputs} $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}; \
done
info:
install-info:
clean-info:
Makefile: Makefile.in config.status @host_makefile_frag_path@
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck

35
libgloss/epiphany/_exit.S Normal file
View File

@ -0,0 +1,35 @@
# EPIPHANY implementation of _exit ()
# Copyright (c) 2011, Adapteva, Inc.
# All rights reserved.
# Contributor Joern Rennecke <joern.rennecke@embecosm.com> for Adapteva Inc
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Adapteva nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. */
.section .text
.global __exit
__exit:
trap #3 ; exit
b __exit

46
libgloss/epiphany/_exit.c Normal file
View File

@ -0,0 +1,46 @@
/* EPIPHANY implementation of _exit ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* ------------------------------------------------------------------------- */
#include "epiphany-syscalls.h"
/* ------------------------------------------------------------------------- */
/* ------------------------------------------------------------------------- */
/*!Exit from execution
This is the interface to the CGEN simulation.
@param[in] rc The return code */
/* ------------------------------------------------------------------------- */
void __attribute__ ((section ("libgloss_epiphany")))
_exit (int rc)
{
asm_exit (rc);
} /* _exit () */

View File

@ -0,0 +1,35 @@
/* isatty.c
Copyright (c) 1994-2009 Red Hat, Inc. All rights reserved.
Copyright (c) 2012 Adapteva, Inc.
This copyrighted material is made available to anyone wishing to use,
modify, copy, or redistribute it subject to the terms and conditions
of the BSD License. This program is distributed in the hope that
it will be useful, but WITHOUT ANY WARRANTY expressed or implied,
including the implied warranties of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE. A copy of this license is available at
http://www.opensource.org/licenses. Any Red Hat trademarks that are
incorporated in the source code or documentation are not subject to
the BSD License and may only be used or replicated with the express
permission of Red Hat, Inc. */
/* Dumb implementation so programs will at least run. */
#include <sys/stat.h>
#include <errno.h>
int
_DEFUN(_isatty, (fd), int fd)
{
struct stat buf;
if (_fstat (fd, &buf) < 0) {
errno = EBADF;
return 0;
}
if (S_ISCHR (buf.st_mode))
return 1;
errno = ENOTTY;
return 0;
}

View File

@ -0,0 +1,32 @@
/* This is file ACCESS.C */
/*
* Copyright (C) 1993 DJ Delorie
* All rights reserved.
*
* Redistribution and use in source and binary forms is permitted
* provided that the above copyright notice and following paragraph are
* duplicated in all such forms.
*
* This file is distributed WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
*/
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>
int access(const char *fn, int flags)
{
struct stat s;
if (stat(fn, &s))
return -1;
if (s.st_mode & S_IFDIR)
return 0;
if (flags & W_OK)
{
if (s.st_mode & S_IWRITE)
return 0;
return -1;
}
return 0;
}

404
libgloss/epiphany/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,404 @@
# generated automatically by aclocal 1.11.1 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 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, 2006, 2008
# 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 9
# 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])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
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, 2006, 2009
# 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 10
# 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], UPC, [depcc="$UPC" am_compiler_list=],
[$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
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
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
# 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. Also, some Intel
# versions had trouble with output in subdirs
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
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
;;
msvisualcpp | msvcmsys)
# This compiler won't grok `-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
if depmode=$depmode \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj 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])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
# 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 5
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[{
# Autoconf 2.62 quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
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.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/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, 2009 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 4
# 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 this is the am__doit target
.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
# Ignore all kinds of additional output from `make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Copyright (C) 2006, 2008 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
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
m4_include([../acinclude.m4])

52
libgloss/epiphany/close.c Normal file
View File

@ -0,0 +1,52 @@
/* EPIPHANY implementation of _close ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include "epiphany-syscalls.h"
/* ------------------------------------------------------------------------- */
/*!Close an open file
When run with the simulator, asm_close () uses the host close routine,
otherwise it is up to the hardware to provide a suitable BSP
implementation. In either case it returns 0 on success or -1 on failure,
and updates errno on failure.
@param[in] filedes The file descriptor to close
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_close (int fildes)
{
return asm_close (fildes);
} /* _close () */

View File

@ -0,0 +1,31 @@
/* config.h.in. Generated from configure.in by autoheader. */
/* .pushsection/.popsection directives allowed */
#undef HAVE_ASM_POPSECTION_DIRECTIVE
/* .previous directive allowed */
#undef HAVE_ASM_PREVIOUS_DIRECTIVE
/* Using ELF format */
#undef HAVE_ELF
/* Using GNU ld */
#undef HAVE_GNU_LD
/* Define to the address where bug reports for this package should be sent. */
#undef PACKAGE_BUGREPORT
/* Define to the full name of this package. */
#undef PACKAGE_NAME
/* Define to the full name and version of this package. */
#undef PACKAGE_STRING
/* Define to the one symbol short name of this package. */
#undef PACKAGE_TARNAME
/* Define to the version of this package. */
#undef PACKAGE_VERSION
/* symbol prefix */
#undef __SYMBOL_PREFIX

4061
libgloss/epiphany/configure vendored Executable file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
# Makefile for libgloss/epiphany
# Copyright (c) 2011, Adapteva, Inc.
# All rights reserved.
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Adapteva nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE. */
# Process this file with autoconf to produce a configure script
AC_PREREQ(2.59)
AC_INIT(libepiphany,0.0.1)
AC_CONFIG_HEADER(config.h)
# No shared libraries allowed
if test "${enable_shared}" = "yes" ; then
echo "Shared libraries not supported for cross compiling, ignored"
fi
# Where are the auxillary tools (confg.sub etc)?
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
AC_DEFINE(HAVE_GNU_LD, 1, [Using GNU ld])
# We always use ELF, define various useful associated things.
AC_DEFINE(HAVE_ELF, 1, [Using ELF format])
# Assembler directives (the assembler handles them, whether it does anything
# useful with them is another matter...
AC_DEFINE(HAVE_ASM_PREVIOUS_DIRECTIVE, 1, [.previous directive allowed])
AC_DEFINE(HAVE_ASM_POPSECTION_DIRECTIVE, 1,
[.pushsection/.popsection directives allowed])
# Section attributes in C don't currently work
#AC_DEFINE(HAVE_SECTION_ATTRIBUTES, 1, [support for section attributes])
# Sort out what the symbol prefix is (we could just fix it as '_', but let the
# script work it out.
AC_CACHE_CHECK([for symbol prefix], libc_symbol_prefix, [dnl
cat > conftest.c <<\EOF
foo () { }
EOF
dnl
libc_symbol_prefix=none
if AC_TRY_COMMAND([${CC-cc} -S conftest.c -o - | fgrep "\$foo" > /dev/null]);
then
libc_symbol_prefix='$'
else
if AC_TRY_COMMAND([${CC-cc} -S conftest.c -o - | fgrep "_foo" > /dev/null]);
then
libc_symbol_prefix=_
fi
fi
rm -f conftest* ])
if test $libc_symbol_prefix != none; then
AC_DEFINE_UNQUOTED(__SYMBOL_PREFIX, "$libc_symbol_prefix", [symbol prefix])
else
AC_DEFINE(__SYMBOL_PREFIX, "", [symbol prefix])
fi
# Standard stuff copied from libnosys. For this we'll need to an aclocal.m4
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,
ac_file=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

166
libgloss/epiphany/crt0.S Normal file
View File

@ -0,0 +1,166 @@
# C Startup for EPIPHANY
# Copyright (c) 2011, Adapteva, Inc.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Adapteva nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
.section IVT,"a",@progbits ;
.global _start;
.type _start, %function;
_start:
.balign 4 ;
b .normal_start
.balign 4 ; 0x4
b .sw_exception_v
.balign 4 ; 0x8
b .page_miss_v;
.balign 4 ; 0xc
b .timer0_expired_v
.balign 4 ; 0x10
b .timer1_expired_v
.balign 4 ; 0x14
b .message_v
.balign 4 ; 0x18
b .dma0_v
.balign 4 ; 0x1c
b .dma1_v
.balign 4 ; 0x20
b .wand_v
.balign 4 ; 0x24
b .soft_v
.size _start, .-_start
.section RESERVED_CRT0,"a",@progbits ;
.global .normal_start;
.balign 4
.type .normal_start, %function
.normal_start:
mov r3,%low(_external_start)
movt r3,%high(_external_start)
jalr r3
.size .normal_start, .-.normal_start
.section .text;
.org 0x0000 ; Relative to start of text section
.global _external_start
.type _external_start, %function
_external_start:
.align 4
;; Initialise the stack pointer and frame pointer. Hopefully __stack
;; is somewhere meaningful.
mov sp,%low(___stack)
movt sp,%high(___stack)
mov fp,sp
;; Zero the data space
mov r0,%low(___bss_start)
movt r0,%high(___bss_start)
mov r1,%low(_end)
movt r1,%high(_end)
mov r2,#0
mov r3,#0
.L0_init_:
strd r2,[r0],+#1
sub r5,r1,r0
bne .L0_init_
;; Setup destructors to be called from exit if main never returns
#if 0
mov r0,%low(fini)
movt r0,%high(fini)
mov r2,%low(_atexit)
movt r2,%high(_atexit)
jalr r2
#else
; calling atexit drags in malloc, so instead poke the function
; address directly into the reent structure
mov r2,%low(__impure_ptr)
movt r2,%high(__impure_ptr)
ldr r2,[r2]
mov r1,%low(fini)
movt r1,%high(fini)
#ifdef __STRUCT_ALIGN_64__
#error
add r2,r2,need_to_find_out; &_GLOBAL_REENT->atexit0
str r2, [r2,-1];??or -2?; _GLOBAL_REENT->atexit
mov r0, 1
str r0, [r2,1] ; _GLOBAL_REENT->atexit0._ind
str r1, [r2,2] ; _GLOBAL_REENT->atexit0._fns[0]
#else /* !__STRUCT_ALIGN_64__ */
add r0,r2,0x14c ; &_GLOBAL_REENT->atexit0
str r0, [r0,-1] ; _GLOBAL_REENT->atexit
mov r0, 1
strd r0, [r2,0x2a] ; _GLOBAL_REENT->atexit0._ind
#endif /* !__STRUCT_ALIGN_64__ */
#endif /* !0 */
;; Call global and static constructors
mov r2,%low(init)
movt r2,%high(init)
jalr r2
;;return from reset ISR
mov R0,%low(RDS)
movt R0,%high(RDS)
movts iret,r0
rti
RDS:
;; Initialise argc, argv and envp to empty and call main
mov r0,#0
mov r1,#0
mov r2,#0
mov r3,%low(_main)
movt r3,%high(_main)
jalr r3
;;bl _main
;; Call exit
mov r3,%low(_exit)
movt r3,%high(_exit)
jalr r3
;;bl _exit
;; Should never reach here
idle
.size _external_start, .-_external_start

View File

@ -0,0 +1,37 @@
/* EPIPHANY implementation of the environ vector
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/*!The empty list is suitable as a minimal implementation of the
environment. */
char *__env[1] = { 0 };
/*!Environment as a pointer to a pointer rather than a pointer to an array. */
char **environ = __env;

View File

@ -0,0 +1,67 @@
/* EPIPHANY builtin and configuration functions ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#ifndef _EPIPHANY_CONFIG_H
#define _EPIPHANY_CONFIG_H
extern unsigned _stack_start_;
extern unsigned _heap_start_;
extern unsigned _heap_end_;
extern unsigned _CORE_NUM_;
enum ECORE_SIGNALS {
#ifndef SIG_DFL
SIG_DFL=0,
#endif
#ifndef SIG_DFL
SIG_IGN=1,
#endif
SIG_RESET=3,
SIG_SW_EXCEPTION=4,
SIG_PAGE_MISS=5,
SIG_TIMER0=6,
SIG_TIMER1=7,
SIG_MESSAGE=8,
SIG_DMA0=9,
SIG_DMA1=10,
SIG_WAND=11,
SIG_USR1=12
#ifndef SIG_ERR
, SIG_ERR=-1
#endif
};
#endif

View File

@ -0,0 +1,192 @@
# EPIPHANY implementation of wrappers over user C ISR ()
# Copyright (c) 2011, Adapteva, Inc.
# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# * Neither the name of Adapteva nor the names of its contributors may be
# used to endorse or promote products derived from this software without
# specific prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
.section RESERVED_CRT0,"a",@progbits ;
.set sw_exception_v_n, 1
.set page_miss_v_n, 2
.set timer0_expired_v_n, 3;
.set timer1_expired_v_n, 4;
.set message_v_n, 5;
.set dma0_v_n, 6;
.set dma1_v_n, 7;
.set wand_v_n, 8;
.set soft_v_n, 9
// preserve isr-mods to ACTIVE, GID, KERNEL, WAND, & EXCAUSE bits in the status reg
.set status_mask, 0x0007000f;
// for the wand isr, preserve isr-mods to ACTIVE, GID, KERNEL, & EXCAUSE, but
// clear the WAND bit.
.set wand_status_mask, 0x00070007;
//IVT wrappers
.global _DEFAULT_ISR_CALLBACK;
.balign 4
.type _DEFAULT_ISR_CALLBACK, %function
_DEFAULT_ISR_CALLBACK:
rts
.size _DEFAULT_ISR_CALLBACK, .-_DEFAULT_ISR_CALLBACK
.global _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v;
.balign 4
.type _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v, %function
_DEFAULT_ISR_CALLBACK_FOR_sw_exception_v:
trap 5;; FAIL
.size _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v, .-_DEFAULT_ISR_CALLBACK_FOR_sw_exception_v
.set NUMBER_ENTRIES_IN_IVT, 8
.global _ISR_VECTOR;
.balign 4
.type _ISR_VECTOR, %object
_ISR_VECTOR:
.word _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v; reset
.word _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v; sw_exception
.word _DEFAULT_ISR_CALLBACK_FOR_sw_exception_v; page_miss
.rept NUMBER_ENTRIES_IN_IVT
.word _DEFAULT_ISR_CALLBACK
.endr
.size _ISR_VECTOR, .-_ISR_VECTOR
.macro IVT_ENTRY_CALL entry_v_
;; assuming we have valid frame poiter
str fp, [sp],-0x10
str r0, [sp,+0xf]
str r1, [sp,+0xe]
mov r0, \entry_v_
.if \entry_v_ == wand_v_n
mov r1, %low(wand_status_mask) ; this mask will exclude WAND, so it will
movt r1, %high(wand_status_mask) ; be forcibly cleared
.else
mov r1, %low(status_mask)
movt r1, %high(status_mask)
.endif
str r1, [sp,0x9] ; save the status register isr-preserve mask on the stack
b __dispatcher
.endm
.global __dispatcher;
.balign 4
.type __dispatcher, %function
__dispatcher:
str lr, [sp,+0xd]
movfs.l r1,status
str r1, [sp,+0xc]
movfs.l r1,iret
str r1, [sp,+0xb]
str r2, [sp,+0xa]
str r3, [sp,+0x8]
mov fp,sp
//TODO allow nesting
//gie
lsl r2, r0, 2
mov r1, %low(_ISR_VECTOR)
add r2, r2, r1
ldr r1, [r2,0] ;; r1 = _ISR_VECTOR[entry_v]
mov r2, 3
add r0, r0, r2 ;; r0 = signum
jalr r1
mov sp,fp
//gid
// preserve isr-modifications to some of the bits in the status register,
// but restore the rest to pre-interrupt values.
// status = (status[post_isr] & status_mask) | (status[pre_isr] & ~status_mask)
ldr.l r2, [sp, 9] ; fetch the status register isr preserve mask from the stack
movfs r1, status
and r1, r1, r2; (status[post_isr] & status_mask)
ldr r0, [sp,+0xc]
mov r2, %low(~status_mask)
movt r2, %high(~status_mask)
and r0, r0, r2; (status[pre_isr] & ~status_mask)
orr r0, r0, r1 ; combine pre_isr & post_isr status bits
movts.l status, r0
ldr r0, [sp,+0xb]
movts.l iret,r0
ldr lr,[sp,+0xd];
ldr r1,[sp,+0xe]
ldr r0,[sp,+0xf]
ldr r2,[sp,+0xa]
ldr r3,[sp,+0x8]
ldr fp,[sp],+0x10
ldr fp,[sp,0]
rti
.size __dispatcher, .-__dispatcher
.global .sw_exception_v;
.type .sw_exception_v, %function
.sw_exception_v:
IVT_ENTRY_CALL sw_exception_v_n;
.size .sw_exception_v, .-.sw_exception_v
.global .page_miss_v;
.type .page_miss_v, %function
.page_miss_v:
IVT_ENTRY_CALL page_miss_v_n;
.size .page_miss_v, .-.page_miss_v
.global .timer0_expired_v;
.timer0_expired_v:
IVT_ENTRY_CALL timer0_expired_v_n;
.global .timer1_expired_v;
.timer1_expired_v:
IVT_ENTRY_CALL timer1_expired_v_n;
.global .message_v;
.message_v:
IVT_ENTRY_CALL message_v_n;
.global .dma0_v;
.dma0_v:
IVT_ENTRY_CALL dma0_v_n;
.global .dma1_v;
.dma1_v:
IVT_ENTRY_CALL dma1_v_n;
.global .wand_v;
.wand_v:
IVT_ENTRY_CALL wand_v_n;
.global .soft_v;
.soft_v:
IVT_ENTRY_CALL soft_v_n;

View File

@ -0,0 +1,271 @@
/* Adapteva epiphany-core implementation of stdio support functions ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
/* simple include interface to EPIPHANY trap instruction. */
/*
* The simulator uses a trap instruction to escape to the simulator to do file i/o
*/
/* trapcode r0 r1 r2 */
#define TRAP_write 0 /* channel addr len */
#define TRAP_read 1 /* channel addr len */
#define TRAP_open 2 /* filepath mode */
#define TRAP_exit 3 /* status */
#define TRAP_pass 4 /* - */
#define TRAP_fail 5 /* - */
#define TRAP_close 6 /* channel */
#define TRAP_other 7 /* subcode r1 r2 */
#include "epiphany-syscalls.h"
/* prototypical inline asm */
int __attribute__ ((section ("libgloss_epiphany"))) asm_write (int CHAN, void* ADDR, int LEN)
{
register int chan asm("r0") = CHAN;
register void* addr asm("r1") = ADDR;
register int len asm("r2") = LEN;
register int result asm("r0");
register int error asm("r3");
asm ("trap 0" : "=r" (result), "=r" (error) :
"r" (chan), "r" (addr), "r" (len));
if (error)
errno = error;
return result;
}
int __attribute__ ((section ("libgloss_epiphany"))) asm_read(int CHAN, void *ADDR, int LEN)
{
register int chan asm("r0") = CHAN;
register void* addr asm("r1") = ADDR;
register int len asm("r2") = LEN;
register int result asm("r0");
register int error asm("r3");
asm ("trap 1" : "=r" (result), "=r" (error) :
"r" (chan), "r" (addr), "r" (len));
if (error)
errno = error;
return result;
}
int __attribute__ ((section ("libgloss_epiphany")))
asm_open(const char* FILE, int FLAGS, int MODE)
{
register const char* file asm("r0") = FILE;
register int flags asm("r1") = FLAGS;
register int result asm("r0");
register int error asm("r3");
asm ("trap 2" : "=r" (result), "=r" (error) : "r" (file), "r" (flags));
if (error)
errno = error;
return result;
}
void __attribute__ ((section ("libgloss_epiphany"))) asm_exit(int STATUS)
{
register int status asm("r0") = STATUS;
asm("trap 3" :: "r" (status));
}
int __attribute__ ((section ("libgloss_epiphany"))) asm_close(int CHAN)
{
register int chan asm("r0") = CHAN;
register int result asm("r0");
register int error asm("r3");
asm ("trap 6" : "=r" (result), "=r" (error) : "r" (chan));
if (error)
errno = error;
return result;
}
int __attribute__ ((section ("libgloss_epiphany"))) asm_syscall(void *P1,void *P2, void *P3, int SUBFUN)
{
register void* p1 asm("r0") = (void*)P1;
register void* p2 asm("r1") = (void*)P2;
register void* p3 asm("r2") = (void*)P3;
register int result asm("r0");
register int subfun asm("r3") = SUBFUN;
register int error asm("r3");
asm ("trap 7" : "=r" (result), "=r" (error) :
"r" (p1), "r" (p2), "r" (p3), "r" (subfun));
if (error)
errno = error;
return result;
}
/*
* Signal functions implementation
*
*/
#include "epiphany-config.h"
#define HW_RESET 0
#define SW_EXCEPTION_IVT_N 1
#define PAGE_MISS_IVT_N 2
#define TIMER0_IVT_N 3
#define TIMER1_IVT_N 4
#define MESSAGE_IVT_N 5
#define DMA0_IVT_N 6
#define DMA1_IVT_N 7
#define WAND_IVT_N 8
#define USR_SOFT_IVT_N 9
typedef void (*sighandler_t)(int);
extern sighandler_t ISR_VECTOR[];
extern void DEFAULT_ISR_CALLBACK();
sighandler_t __attribute__ ((section ("libgloss_epiphany"))) signal(int signum, sighandler_t handler) {
switch( signum )
{
case SIG_DFL /* see signal.h */:
//the default is ignore
break;
case SIG_IGN /* see signal.h */ :
DEFAULT_ISR_CALLBACK();
break;
case SIG_ERR :
asm("trap 5");
break;
case SIG_RESET:
ISR_VECTOR[HW_RESET] = handler;
break;
case SIG_SW_EXCEPTION:
ISR_VECTOR[SW_EXCEPTION_IVT_N] = handler;
break;
case SIG_PAGE_MISS:
ISR_VECTOR[PAGE_MISS_IVT_N] = handler;
break;
case SIG_TIMER0:
ISR_VECTOR[TIMER0_IVT_N] = handler;
break;
case SIG_TIMER1:
ISR_VECTOR[TIMER1_IVT_N] = handler;
break;
case SIG_MESSAGE:
ISR_VECTOR[MESSAGE_IVT_N] = handler;
break;
case SIG_DMA0:
ISR_VECTOR[DMA0_IVT_N] = handler;
break;
case SIG_DMA1:
ISR_VECTOR[DMA1_IVT_N] = handler;
break;
case SIG_WAND:
ISR_VECTOR[WAND_IVT_N] = handler;
break;
case SIG_USR1:
ISR_VECTOR[USR_SOFT_IVT_N] = handler;
break;
default:
//do nothing
return 0;
}
return 0;
}
//int e_raise(int signum) __attribute__ ((optimize("O0")));
int __attribute__ ((section ("libgloss_epiphany"))) e_raise(int signum) {
//register int imask asm("r4") = 0 ;
volatile register int ilatst /*asm("r5") */= signum;
switch( signum )
{
case SIG_DFL /* see signal.h */:
//the default is ignore
return 0;
case SIG_IGN /* see signal.h */ :
//do nothing
return 0;
case SIG_ERR :
return 0;
case SIG_RESET:
//imask = 1 << HW_RESET;
ilatst = 1 << HW_RESET;
break;
case SIG_SW_EXCEPTION:
//imask = 1 << SW_EXCEPTION_IVT_N;
ilatst = 1 << SW_EXCEPTION_IVT_N;
break;
case SIG_PAGE_MISS:
//imask = 1 << PAGE_MISS_IVT_N;
ilatst = 1 << PAGE_MISS_IVT_N;
break;
case SIG_TIMER0:
//imask = 1 << TIMER0_IVT_N;
ilatst = 1 << TIMER0_IVT_N;
break;
case SIG_TIMER1:
//imask = 1 << TIMER1_IVT_N;
ilatst = 1 << TIMER1_IVT_N;
break;
case SIG_MESSAGE:
//imask = 1 << MESSAGE_IVT_N;
ilatst = 1 << MESSAGE_IVT_N;
break;
case SIG_DMA0:
//imask = 1 << DMA0_IVT_N;
ilatst = 1 << DMA0_IVT_N;
break;
case SIG_DMA1:
//imask = 1 << DMA1_IVT_N;
ilatst = 1 << DMA1_IVT_N;
break;
case SIG_WAND:
__asm__ __volatile__ ("wand");
//ilatst = 1 << WAND_IVT_N;
//break;
return;
case SIG_USR1:
ilatst = 1 << USR_SOFT_IVT_N;
break;
default:
//do nothing
return 0;
}
//asm("movts imask, r4;");
//asm("movts ilatst, r5;");
__asm__ __volatile__ ("movts ilatst, %0" : "=r" (ilatst) : "r" (ilatst));
return 0;
}

View File

@ -0,0 +1,39 @@
/* Adapteva e-core implementation of stdio support functions ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#ifndef __EPIPHANY_SIM_H_
#define __EPIPHANY_SIM_H_
int asm_write (int CHAN, void* ADDR, int LEN);
int asm_read(int CHAN, void *ADDR, int LEN);
int asm_open(const char* FILE, int FLAGS, int MODE);
void asm_exit(int STATUS);
int asm_close(int CHAN);
int asm_syscall(void *P1, void *P2, void *P3, int SUBFUN);
#endif

View File

@ -0,0 +1,56 @@
/* EPIPHANY implementation of _execve ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include <sys/types.h>
/* ------------------------------------------------------------------------- */
/*!Transfer control to a new process.
This is a minimal implementation, which always fails (there are no
processes)!
@todo Is this a permissible errno?
@param[in] filename The file to execute
@param[in] argv Null terminated list of args to the program
@param[in] envp Null terminated list of environment value pairs
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_execve (const char *filename, char * const argv[], char * const envp[])
{
errno = ENOSYS; /* We don't do processes */
return -1;
} /* _execve () */

52
libgloss/epiphany/fork.c Normal file
View File

@ -0,0 +1,52 @@
/* EPIPHANY implementation of _fork ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include <sys/types.h>
/* ------------------------------------------------------------------------- */
/*!Create a new process
This is a minimal implementation, which always fails, since we have no
processes.
@todo Is this a permissible errno?
@return pid of the child (returning the parent), 0 (returning in the
parent) on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
pid_t __attribute__ ((section ("libgloss_epiphany")))
_fork (void)
{
errno = ENOSYS;
return -1;
} /* _fork () */

49
libgloss/epiphany/fstat.c Normal file
View File

@ -0,0 +1,49 @@
/* EPIPHANY implementation of _fstat ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <sys/stat.h>
#include <syscall.h>
/* ------------------------------------------------------------------------- */
/*!Status of an open file
@param[in] fildes File descriptor for which status is sought
@param[out] st Structure for the status information
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_fstat (int fildes, struct stat *st)
{
return asm_syscall (fildes, st, NULL, SYS_fstat);
} /* _fstat () */

View File

@ -0,0 +1,47 @@
/* EPIPHANY implementation of _getpid ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <sys/types.h>
/* ------------------------------------------------------------------------- */
/*!Get the process ID
A minimal implementation is best advised to return 1, the number of the
only process. This means the code will work for programs which generate
filenames based on the PID.
@return the PID. This function never fails. */
/* ------------------------------------------------------------------------- */
pid_t __attribute__ ((section ("libgloss_epiphany")))
_getpid (void)
{
return 1;
} /* _getpid () */

View File

@ -0,0 +1,39 @@
/* EPIPHANY implementation of _stat ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Joern Rennecke <joern.rennecke@embecosm.com> for Adapteva Inc.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include <sys/time.h>
#include "syscall.h"
int
_gettimeofday (struct timeval *tp, void *tzp)
{
return asm_syscall (tp, tzp, NULL, SYS_gettimeofday);
}

52
libgloss/epiphany/kill.c Normal file
View File

@ -0,0 +1,52 @@
/* EPIPHANY implementation of _kill ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include <sys/types.h>
/* ------------------------------------------------------------------------- */
/*!Send a signal
This is a minimal implementation, just call the internal rise
@param[in] pid The process that should receive the signal
@param[in] sig The signal to send
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
extern int e_raise(int signum);
int __attribute__ ((section ("libgloss_epiphany")))
_kill (pid_t pid, int sig)
{
//errno = EINVAL;
return e_raise(sig);
} /* _kill () */

53
libgloss/epiphany/link.c Normal file
View File

@ -0,0 +1,53 @@
/* EPIPHANY implementation of _link ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <unistd.h>
#include <syscall.h>
/* ------------------------------------------------------------------------- */
/*!Establish a new name for an existing file.
Call an assembly function which will generate a system call trap. Either
the simulator host file system or the hardware BSP must provide the
functionality.
@param[in] old The existing file name
@param[in] new The new file name
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_link (const char *old, const char *new)
{
return asm_syscall (old, new, NULL, SYS_link);
} /* _link () */

47
libgloss/epiphany/lseek.c Normal file
View File

@ -0,0 +1,47 @@
/* EPIPHANY implementation of _lseek ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <syscall.h>
#include <sys/types.h>
/* ------------------------------------------------------------------------- */
/*!Set a position in a file
@param[in] fildes The file descriptor on which to seek
@param[in] offset The desired offset
@param[in] whence Where the offset is measured from
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
off_t __attribute__ ((section ("libgloss_epiphany")))
_lseek (int fildes, off_t offset, int whence)
{
return asm_syscall (fildes, offset, whence, SYS_lseek);
} /* _lseek () */

49
libgloss/epiphany/open.c Normal file
View File

@ -0,0 +1,49 @@
/* EPIPHANY implementation of _open ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <sys/types.h>
#include "epiphany-syscalls.h"
#include "syscall.h"
/* ------------------------------------------------------------------------- */
/*!Open a file
@param[in] file The name of the file to open
@param[in] flags The flags definining how the file should be opened
@param[in] mode The permissions to be used in the new file
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_open (const char *file, int flags, mode_t mode)
{
return asm_open (file, flags, mode);
} /* _open () */

49
libgloss/epiphany/read.c Normal file
View File

@ -0,0 +1,49 @@
/* EPIPHANY implementation of _read ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <sys/types.h>
#include "epiphany-syscalls.h"
#include "syscall.h"
/* ------------------------------------------------------------------------- */
/*!Read a file
@param[in] fildes The descriptor of the file from which to read
@param[in] ptr Buffer for the read data
@param[in] len Maximum number of bytes to read
@return Number of bytes read on success, -1 on failure with an error code
in errno. */
/* ------------------------------------------------------------------------- */
ssize_t __attribute__ ((section ("libgloss_epiphany")))
_read (int fildes, void *ptr, size_t len)
{
return asm_read (fildes, ptr, len);
} /* _read () */

165
libgloss/epiphany/sbrk.c Normal file
View File

@ -0,0 +1,165 @@
/* EPIPHANY implementation of _sbrk ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
/* ------------------------------------------------------------------------- */
/* This implementation is suitable for use with the Verilator simulation of
the EPIPHANY.
Commenting suitable for processing by Doxygen is provided throughout. */
/* ------------------------------------------------------------------------- */
#include <sys/types.h>
#include <errno.h>
#include <stddef.h>
/* ------------------------------------------------------------------------- */
/*!Increase program data space
This is a minimal implementation. Assuming the heap is growing upwards
from __heap_start towards __heap_end.
See linker file for definition.
@param[in] incr The number of bytes to increment the stack by.
@return A pointer to the start of the new block of memory */
/* ------------------------------------------------------------------------- */
void *
_sbrk (int incr)
{
extern char __heap_start;//set by linker
extern char __heap_end;//set by linker
static char *heap_end; /* Previous end of heap or 0 if none */
char *prev_heap_end;
if (0 == heap_end) {
heap_end = &__heap_start; /* Initialize first time round */
}
prev_heap_end = heap_end;
heap_end += incr;
//check
if( heap_end < (&__heap_end)) {
} else {
errno = ENOMEM;
return (char*)-1;
}
return (void *) prev_heap_end;
} /* _sbrk () */
///* sbrk support */
//
///* The current plan is to have one sbrk handler for all cpus.
// Hence use `asm' for each global variable here to avoid the cpu prefix.
// We can't intrude on the user's namespace (another reason to use asm). */
//
//#include <sys/types.h>
///*#include <sys/syscall.h>*/
//#include <errno.h>
//#include <stddef.h>
//
///* These variables are publicly accessible for debugging purposes.
// The user is also free to set sbrk_size to something different.
// See mem-layout.c. */
//
//extern int sbrk_size asm ("sbrk_size");
//
//caddr_t sbrk_start asm ("sbrk_start");
//caddr_t sbrk_loc asm ("sbrk_loc");
//extern char end; /* Defined by linker. */
//
///*caddr_t _sbrk_r (struct _reent *, size_t) asm ("__sbrk_r");*/
//
//
///* This symbol can be defined with the --defsym linker option. */
//extern char __heap_end __attribute__((weak));
//
//
///* FIXME: We need a semaphore here. */
//
//caddr_t
//_sbrk_r (struct _reent *r, size_t nbytes)
//{
// extern char end; /* Defined by linker. */
// static char *heap_end; /* Previous end of heap or 0 if none */
// char *prev_heap_end;
// register char* stack asm("sp");
//
// if (0 == heap_end)
// {
// heap_end = &end; /* Initialize first time round */
// }
//
// prev_heap_end = heap_end;
//
// if (stack < (prev_heap_end+nbytes)) {
// /* heap would overlap the current stack depth.
// * Future: use sbrk() system call to make simulator grow memory beyond
// * the stack and allocate that
// */
// errno = ENOMEM;
// return (char*)-1;
// }
//
// heap_end += nbytes;
//
// return (caddr_t) prev_heap_end;
//
//} /* _sbrk () */
//caddr_t
//_sbrk_r (struct _reent *r, size_t nbytes)
//{
// caddr_t result;
//
// void *heap_end;
//
// heap_end = &__heap_end;
// if (!heap_end)
// heap_end = sbrk_start + sbrk_size;
// if (
// /* Ensure we don't underflow. */
// sbrk_loc + nbytes < sbrk_start
// /* Ensure we don't overflow. */
// || sbrk_loc + nbytes > (caddr_t)heap_end)
// {
// errno = ENOMEM;
// return ((caddr_t) -1);
// }
//
// if (0 == sbrk_loc)
// sbrk_loc = &end; /* Initialize first time round */
// result = sbrk_loc;
// sbrk_loc += nbytes;
// return result;
//}

48
libgloss/epiphany/stat.c Normal file
View File

@ -0,0 +1,48 @@
/* EPIPHANY implementation of _stat ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <sys/stat.h>
#include <syscall.h>
/* ------------------------------------------------------------------------- */
/*!Status of a file (by name)
@param[in] file Name of the file for which status is sought
@param[out] st Structure for the status information
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_stat (const char *file, struct stat *st)
{
return asm_syscall (file, st, NULL, SYS_stat);
} /* _stat () */

53
libgloss/epiphany/times.c Normal file
View File

@ -0,0 +1,53 @@
/* EPIPHANY implementation of _times ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include <sys/times.h>
/* ------------------------------------------------------------------------- */
/*!Get timing information for current process
This is a minimal implementation, which always fails
@todo Is this a permissible errno?
@param[out] buf Buffer for timing information
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
clock_t __attribute__ ((section ("libgloss_epiphany")))
_times (struct tms *buf)
{
errno = ENOSYS;
return -1;
} /* _times () */

View File

@ -0,0 +1,53 @@
/* EPIPHANY implementation of _unlink ()
Copyright (c) 2011, Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <unistd.h>
#include <syscall.h>
/* ------------------------------------------------------------------------- */
/*!Remove a file
Call an assembly function which will generate a system call trap. Either
the simulator host file system or the hardware BSP must provide the
functionality.
@param[in] name Name of file to remove
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
int __attribute__ ((section ("libgloss_epiphany")))
_unlink (const char *name)
{
return asm_syscall (name, NULL, NULL, SYS_unlink);
} /* _unlink () */

52
libgloss/epiphany/wait.c Normal file
View File

@ -0,0 +1,52 @@
/* EPIPHANY implementation of _wait ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <errno.h>
#include <sys/types.h>
/* ------------------------------------------------------------------------- */
/*!Wait for a child process
This is a minimal implementation, which always fails, since we have only
one process.
@param[out] status Status information about the file waited for.
@return 0 on success, -1 on failure with an error code in errno. */
/* ------------------------------------------------------------------------- */
pid_t __attribute__ ((section ("libgloss_epiphany")))
_wait (int *status)
{
errno = ENOSYS;
return -1;
} /* _wait () */

52
libgloss/epiphany/write.c Normal file
View File

@ -0,0 +1,52 @@
/* EPIPHANY implementation of _write ()
Copyright (c) 2011, 2012 Adapteva, Inc.
All rights reserved.
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com> for Adapteva Inc
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of Adapteva nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE. */
#include <sys/types.h>
#include "epiphany-syscalls.h"
#include "syscall.h"
/* ------------------------------------------------------------------------- */
/*!Write to a file
CGEN simulator file output.
@param[in] fildes File descriptor to write to
@param[in] ptr Buffer of data to write
@param[in] len Number of bytes to write
@return Number of bytes written on success, -1 on failure with an error
code in errno. */
/* ------------------------------------------------------------------------- */
ssize_t __attribute__ ((section ("libgloss_epiphany")))
_write (int file, const void *ptr, size_t len)
{
return asm_write (file, ptr, len);
} /* _write () */