mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-01-18 20:39:33 +08:00
Add C-SKY port for libgloss
This patch contain all libgloss for C-SKY Contributor list: - Lifang Xia <lifang_xia@c-sky.com> - Jojo R <jiejie_rong@c-sky.com> - Xianmiao Qu <xianmiao_qu@c-sky.com> - Yunhai Shang <yunhai_shang@c-sky.com>
This commit is contained in:
parent
c1f7c4d1b6
commit
648365e0e9
@ -452,3 +452,29 @@ 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.
|
||||
|
||||
(22) CodeSourcery, Inc (csky-* targets)
|
||||
|
||||
Copyright (c) 2006 CodeSourcery Inc
|
||||
|
||||
The authors hereby grant permission to use, copy, modify, distribute,
|
||||
and license this software and its documentation for any purpose, provided
|
||||
that existing copyright notices are retained in all copies and that this
|
||||
notice is included verbatim in any distributions. No written agreement,
|
||||
license, or royalty fee is required for any of the authorized uses.
|
||||
Modifications to this software may be copyrighted by their authors
|
||||
and need not follow the licensing terms described here, provided that
|
||||
the new terms are clearly indicated on the first page of each file where
|
||||
they apply.
|
||||
|
||||
(23) - C-SKY Microsystems (csky-* targets)
|
||||
|
||||
Copyright (c) 2020 C-SKY Microsystems All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the FreeBSD 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.
|
||||
|
||||
|
5
libgloss/configure
vendored
5
libgloss/configure
vendored
@ -667,6 +667,7 @@ CCASFLAGS'
|
||||
ac_subdirs_all='doc
|
||||
aarch64
|
||||
arc
|
||||
csky
|
||||
epiphany
|
||||
i386
|
||||
m32r
|
||||
@ -2409,6 +2410,10 @@ case "${target}" in
|
||||
arc*-*-*)
|
||||
subdirs="$subdirs arc"
|
||||
|
||||
;;
|
||||
csky*-*-*)
|
||||
subdirs="$subdirs csky"
|
||||
|
||||
;;
|
||||
epiphany-*-*)
|
||||
subdirs="$subdirs epiphany"
|
||||
|
@ -41,6 +41,9 @@ case "${target}" in
|
||||
arc*-*-*)
|
||||
AC_CONFIG_SUBDIRS(arc)
|
||||
;;
|
||||
csky*-*-*)
|
||||
AC_CONFIG_SUBDIRS(csky)
|
||||
;;
|
||||
epiphany-*-*)
|
||||
AC_CONFIG_SUBDIRS(epiphany)
|
||||
config_testsuite=true
|
||||
|
128
libgloss/csky/Makefile.in
Normal file
128
libgloss/csky/Makefile.in
Normal file
@ -0,0 +1,128 @@
|
||||
# Copyright (c) 1995, 1996, 2001 Cygnus Support -*- mode:makefile -*-
|
||||
#
|
||||
# The authors hereby grant permission to use, copy, modify, distribute,
|
||||
# and license this software and its documentation for any purpose, provided
|
||||
# that existing copyright notices are retained in all copies and that this
|
||||
# notice is included verbatim in any distributions. No written agreement,
|
||||
# license, or royalty fee is required for any of the authorized uses.
|
||||
# Modifications to this software may be copyrighted by their authors
|
||||
# and need not follow the licensing terms described here, provided that
|
||||
# the new terms are clearly indicated on the first page of each file where
|
||||
# they apply.
|
||||
#
|
||||
# csky semihosting support.
|
||||
#
|
||||
|
||||
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@
|
||||
AR = @AR@
|
||||
LD = @LD@
|
||||
RANLIB = @RANLIB@
|
||||
AR_FLAGS = qv
|
||||
|
||||
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`
|
||||
|
||||
DO = @DO@
|
||||
|
||||
CRT0=crt0.S
|
||||
|
||||
#
|
||||
# here's all the hosted stuff
|
||||
#
|
||||
HOSTED_BSP= libsemi.a
|
||||
HOSTED_SRS= io-semi.S
|
||||
HOSTED_SRC= sbrk.c io-gdb.c io-exit.c io-close.c io-fstat.c io-gettimeofday.c \
|
||||
io-lseek.c io-read.c io-system.c io-unlink.c io-exit.c \
|
||||
io-gdb.c io-isatty.c io-open.c io-rename.c io-stat.c \
|
||||
io-time.c io-write.c kill.o getpid.o
|
||||
HOSTED_OBJS= $(patsubst %.c,%.o,$(HOSTED_SRC))
|
||||
|
||||
INCLUDES+= -I/home/xialf/workspace/newlib-2.5.0.20171222/newlib/libc/include
|
||||
|
||||
# Host specific makefile fragment comes in here.
|
||||
@host_makefile_frag@
|
||||
|
||||
all :: $(HOSTED_BSP)
|
||||
|
||||
#
|
||||
# here's where we build the board support packages for each target
|
||||
#
|
||||
|
||||
# build hosted library
|
||||
$(HOSTED_OBJS) : %.o : %.c
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -nostdlib -DHOSTED=1 $(INCLUDES) -c $< -o $@
|
||||
$(HOSTED_SRS:%.S=%.o): %.o : %.S
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -nostdlib -DHOSTED=1 $(INCLUDES) -c $< -o $@
|
||||
|
||||
$(HOSTED_BSP): $(HOSTED_OBJS) $(HOSTED_SRS:%.S=%.o)
|
||||
${AR} ${ARFLAGS} $@ $^
|
||||
${RANLIB} $@
|
||||
|
||||
crt0.o: $(CRT0)
|
||||
$(CC) $(CFLAGS_FOR_TARGET) $(CFLAGS) -c $< -o $@
|
||||
|
||||
.PHONY: install info dvi doc install-info clean-info
|
||||
install:: $(DO:%=install_%) crt0.o
|
||||
$(INSTALL_PROGRAM) crt0.o $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(crt0.o)
|
||||
|
||||
$(DO:%=install_%): install_hosted
|
||||
|
||||
.PHONY:install_hosted
|
||||
install_hosted::
|
||||
$(INSTALL_PROGRAM) $(HOSTED_BSP) $(DESTDIR)$(tooldir)/lib${MULTISUBDIR}/$(HOSTED_BSP)
|
||||
|
||||
# target specific makefile fragment comes in here.
|
||||
@target_makefile_frag@
|
||||
|
||||
clean mostlyclean:
|
||||
rm -f a.out core *.i *~ *.a *.o *-test *.srec *.dis *.x *.map
|
||||
|
||||
distclean maintainer-clean realclean: clean
|
||||
rm -f Makefile config.cache config.log config.status
|
||||
|
||||
info dvi doc:
|
||||
install-info:
|
||||
clean-info:
|
||||
|
||||
Makefile: Makefile.in config.status @host_makefile_frag_path@ @target_makefile_frag_path@
|
||||
$(SHELL) config.status
|
||||
|
||||
config.status: configure
|
||||
$(SHELL) config.status --recheck
|
409
libgloss/csky/aclocal.m4
vendored
Normal file
409
libgloss/csky/aclocal.m4
vendored
Normal file
@ -0,0 +1,409 @@
|
||||
# generated automatically by aclocal 1.11.6 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
|
||||
# 2005, 2006, 2007, 2008, 2009, 2010, 2011 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,
|
||||
# 2010, 2011 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 12
|
||||
|
||||
# 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'.
|
||||
rm -rf conftest.dir
|
||||
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
|
||||
;;
|
||||
msvc7 | msvc7msys | 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='\'
|
||||
am__nodep='_no'
|
||||
fi
|
||||
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
|
||||
AC_SUBST([AMDEPBACKSLASH])dnl
|
||||
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
|
||||
AC_SUBST([am__nodep])dnl
|
||||
_AM_SUBST_NOTMAKE([am__nodep])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, 2010 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
# with or without modifications, as long as this notice is preserved.
|
||||
|
||||
# serial 3
|
||||
|
||||
# _AM_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])
|
4900
libgloss/csky/configure
vendored
Executable file
4900
libgloss/csky/configure
vendored
Executable file
File diff suppressed because it is too large
Load Diff
93
libgloss/csky/configure.in
Normal file
93
libgloss/csky/configure.in
Normal file
@ -0,0 +1,93 @@
|
||||
# Copyright (c) 1995, 1996 Cygnus Support
|
||||
#
|
||||
# The authors hereby grant permission to use, copy, modify, distribute,
|
||||
# and license this software and its documentation for any purpose, provided
|
||||
# that existing copyright notices are retained in all copies and that this
|
||||
# notice is included verbatim in any distributions. No written agreement,
|
||||
# license, or royalty fee is required for any of the authorized uses.
|
||||
# Modifications to this software may be copyrighted by their authors
|
||||
# and need not follow the licensing terms described here, provided that
|
||||
# the new terms are clearly indicated on the first page of each file where
|
||||
# they apply.
|
||||
#
|
||||
# process this file with autoconf to produce a configure script.
|
||||
AC_PREREQ(2.59)
|
||||
AC_INIT(crt0.S)
|
||||
|
||||
if test "${enable_shared}" = "yes" ; then
|
||||
echo "Shared libraries not supported for cross compiling, ignored"
|
||||
fi
|
||||
|
||||
if test "$srcdir" = "." ; then
|
||||
if test "${with_target_subdir}" != "." ; then
|
||||
libgloss_topdir="${with_multisrctop}../../.."
|
||||
else
|
||||
libgloss_topdir="${with_multisrctop}../.."
|
||||
fi
|
||||
else
|
||||
libgloss_topdir="${srcdir}/../.."
|
||||
fi
|
||||
|
||||
AC_CONFIG_AUX_DIR($libgloss_topdir)
|
||||
AC_CANONICAL_SYSTEM
|
||||
AC_ARG_PROGRAM
|
||||
|
||||
AC_PROG_INSTALL
|
||||
|
||||
LIB_AC_PROG_CC
|
||||
|
||||
AS=${AS-as}
|
||||
AC_SUBST(AS)
|
||||
AR=${AR-ar}
|
||||
AC_SUBST(AR)
|
||||
LD=${LD-ld}
|
||||
AC_SUBST(LD)
|
||||
AC_PROG_RANLIB
|
||||
LIB_AM_PROG_AS
|
||||
|
||||
AC_MSG_CHECKING([target cpu family])
|
||||
DO=csky
|
||||
dnl Temporarily modify LDFLAGS so that link tests will succeed without
|
||||
dnl a C library. Note that we may not have a C librabry yet and that
|
||||
dnl autoconf automatically adds script to check whether we can create
|
||||
dnl an executable or not.
|
||||
dnl
|
||||
saved_LDFLAGS="$LDFLAGS"
|
||||
LDFLAGS="-nostdlib -e main"
|
||||
AC_PREPROC_IFELSE([#ifndef __mcoldfire__
|
||||
#error we are not coldfire
|
||||
#endif],
|
||||
DO="cf",)
|
||||
AC_PREPROC_IFELSE([#ifndef __mfido__
|
||||
#error we are not fido
|
||||
#endif],
|
||||
DO="fido",)
|
||||
LDFLAGS=$saved_LDFLAGS
|
||||
AC_MSG_RESULT($DO)
|
||||
AC_SUBST(DO)
|
||||
|
||||
host_makefile_frag=${srcdir}/../config/default.mh
|
||||
target_makefile_frag=${srcdir}/../config/default.mt
|
||||
|
||||
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)
|
||||
target_makefile_frag_path=$target_makefile_frag
|
||||
AC_SUBST(target_makefile_frag_path)
|
||||
AC_SUBST_FILE(target_makefile_frag)
|
||||
|
||||
AC_CONFIG_FILES(Makefile,
|
||||
. ${libgloss_topdir}/config-ml.in,
|
||||
srcdir=${srcdir}
|
||||
target=${target}
|
||||
with_multisubdir=${with_multisubdir}
|
||||
ac_configure_args="${ac_configure_args} --enable-multilib"
|
||||
CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
|
||||
libgloss_topdir=${libgloss_topdir}
|
||||
)
|
||||
AC_OUTPUT
|
||||
|
180
libgloss/csky/crt0.S
Normal file
180
libgloss/csky/crt0.S
Normal file
@ -0,0 +1,180 @@
|
||||
/*
|
||||
* crt0.S -- startup codes for CK-CPU.
|
||||
*
|
||||
* Define a exception vector table
|
||||
*
|
||||
* Initial PSR register.
|
||||
* Initial VBR register, relocate exception vector table.
|
||||
* Initial sp(stack pointer) register.
|
||||
* Initial MGU (for ckcpu having MGU)
|
||||
* Initial Cache.
|
||||
* Initial SPM (for ckcpu having SPM).
|
||||
* Initial BSS section to "0"
|
||||
* Then goto "main".
|
||||
*
|
||||
* Copyright (c) 2020 C-SKY Microsystems All rights reserved.
|
||||
*/
|
||||
|
||||
.file "crt0.S"
|
||||
/*
|
||||
* MGU & CACHE macro from "ck5a6.h"
|
||||
*
|
||||
* CONFIG_CKCPU_MGU_BLOCKS ---- MGU block priority setting value
|
||||
* CONFIG_CKCPU_MGU_REGION(1-4)
|
||||
* ---- MGU (1-4) block base address and size.
|
||||
* CONFIG_CKCPU_ICACHE ---- Instruction cache enable
|
||||
* CONFIG_CKCPU_DCACHE ---- Data cache enable
|
||||
*
|
||||
* SPM macro from "ck5a6.h"
|
||||
*
|
||||
* CONFIG_CKCPU_SPM ---- CKCPU having SPM ?
|
||||
* CONFIG_CKCPU_SPM_ENABLE ---- SPM Enable
|
||||
* CONFIG_CKCPU_ISPM_MODE ---- Instruction SPM Mode(cache/local memory)
|
||||
* CONFIG_CKCPU_DSPM_MODE ---- Data SPM Mode (cache/local memory)
|
||||
* CONFIG_CKCPU_ISPM_ADDRESS
|
||||
* ---- Instruction SPM external memory base address,
|
||||
* Just for Local Memory Mode
|
||||
* CONFIG_CKCPU_DSPM_ADDRESS
|
||||
* ---- Data SPM external memory base address, Just
|
||||
* for Local Memory Mode
|
||||
* CONFIG_CKCPU_ISPM_TRANSFER
|
||||
* ---- The content in Instruction SPM must be
|
||||
* initialed, Just for Local Memory Mode
|
||||
* CONFIG_CKCPU_DSPM_TRANSFER
|
||||
* ---- The content in Data SPM must be initialed,
|
||||
* Just for Local Memory Mode
|
||||
*/
|
||||
|
||||
/*
|
||||
* For importing variable or functions from script file "ckcpu.ld".
|
||||
*/
|
||||
.import __stack /* The stack pointer from linking script file */
|
||||
.import __fstack /* The fast interrupt stack from linking script file */
|
||||
.import __sbss /* The end of bss from linking script file */
|
||||
.import __ebss /* The end of bss from linking script file */
|
||||
.import __csky_exit /* For QEMU exit. */
|
||||
|
||||
/*
|
||||
* For importing variable or functions from other c or assemble files.
|
||||
*/
|
||||
.import main /* The c codes entry */
|
||||
.import spm_init /* Initial ckcpu SPM */
|
||||
.import exit
|
||||
.import __libc_init_array
|
||||
|
||||
/*
|
||||
* For importing variable or functions from entry.S.
|
||||
*/
|
||||
/* default exception service routine */
|
||||
/*
|
||||
.import default_exception_handler
|
||||
*/
|
||||
|
||||
/* For exporting varialbe or functions */
|
||||
.export ckcpu_vsr_table /* Vector table base address. */
|
||||
.export __start /* The system entry. */
|
||||
|
||||
.text
|
||||
/* Vector table space. */
|
||||
.align 10
|
||||
ckcpu_vsr_table:
|
||||
.rept 128
|
||||
.long __default_exception_handler
|
||||
.endr
|
||||
|
||||
/* The ckcpu startup codes. */
|
||||
.text
|
||||
/*
|
||||
*
|
||||
* This is the codes first entry point. This is where it all
|
||||
* begins...
|
||||
*/
|
||||
.long __start
|
||||
|
||||
__start:
|
||||
/*
|
||||
* Init psr value, enable exception, disable interrupt and fast interrupt.
|
||||
* psr = 0x80000100
|
||||
*/
|
||||
lrw r7, 0
|
||||
bseti r7, 31
|
||||
bseti r7, 8
|
||||
mtcr r7, psr
|
||||
|
||||
/*
|
||||
* Setup initial vector base table for interrupts and exceptions
|
||||
*/
|
||||
lrw r6, ckcpu_vsr_table
|
||||
mtcr r6, vbr
|
||||
|
||||
/* Initialize the normal stack pointer from the linker definition. */
|
||||
lrw r7, __stack
|
||||
mov sp, r7
|
||||
|
||||
#ifdef FAST_INTERRUPT_ENABLE
|
||||
/* Initialize the fast interrupt stack pointer . */
|
||||
psrset af
|
||||
lrw r6, __fstack
|
||||
mov sp, r6
|
||||
psrclr af
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Initial CKCPU MGU & Cache
|
||||
* Step 1: Disable MGU & Cache.
|
||||
*/
|
||||
movi r7, 0
|
||||
mtcr r7, cr18
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* Zero out the bss region.
|
||||
* NOTE: __sbss must align 4
|
||||
*/
|
||||
lrw r7, __sbss /* Get start of bss from linking script file */
|
||||
lrw r6, __ebss /* Get end of bss from linking script file */
|
||||
subu r6, r7 /* Calculate size of bss */
|
||||
lsri r6, r6, 2 /* Size of whole words */
|
||||
cmpnei r6, 0
|
||||
bf __goto_c
|
||||
movi r5, 0 /* Set zero value to write */
|
||||
2:
|
||||
stw r5, (r7) /* Zero next word */
|
||||
addi r7, 4 /* Increase bss pointer */
|
||||
subi r6, 1 /* Decrease counter */
|
||||
cmpnei r6, 0
|
||||
bt 2b /* Repeat for all bss */
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Assember start up done, C codes start here.
|
||||
*/
|
||||
__goto_c:
|
||||
/*jsri main*/
|
||||
lrw r5, __libc_init_array
|
||||
jsr r5
|
||||
/*Set the argc and argv to NULL. */
|
||||
movi r0, 0
|
||||
movi r1, 0
|
||||
lrw r5, main
|
||||
jsr r5
|
||||
|
||||
/* Should never get here. */
|
||||
jbsr exit
|
||||
|
||||
__csky_exit:
|
||||
br __csky_exit
|
||||
|
||||
__default_exception_handler:
|
||||
lrw r4, __csky_exit
|
||||
movi r5, 0x2
|
||||
stw r5, (r4, 0)
|
||||
br __default_exception_handler
|
||||
rte
|
||||
|
||||
.data
|
||||
.align 4
|
||||
__stack_bottom:
|
||||
.rept 128
|
||||
.long 0x0
|
||||
.endr
|
22
libgloss/csky/getpid.c
Normal file
22
libgloss/csky/getpid.c
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* kill.c
|
||||
*
|
||||
* Copyright (c) 2018 Mentor Graphics
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
/* Minimal implementation of getpid for a target system without processes. */
|
||||
int
|
||||
getpid ()
|
||||
{
|
||||
return 1;
|
||||
}
|
43
libgloss/csky/io-close.c
Normal file
43
libgloss/csky/io-close.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* io-close.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO close
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* close -- close a file descriptor.
|
||||
* input parameters:
|
||||
* 0 : file descriptor
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int close (int fd)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret = 0;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
ret = __hosted (HOSTED_CLOSE, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
29
libgloss/csky/io-exit.c
Normal file
29
libgloss/csky/io-exit.c
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* io-exit.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#if HOSTED
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* _exit -- Exit from the application.
|
||||
*/
|
||||
|
||||
void __attribute__ ((noreturn)) _exit (int code)
|
||||
{
|
||||
while (1)
|
||||
__hosted (HOSTED_EXIT, (void *)code);
|
||||
}
|
||||
#endif
|
50
libgloss/csky/io-fstat.c
Normal file
50
libgloss/csky/io-fstat.c
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* io-fstat.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO fstat
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* fstat -- get file information
|
||||
* input parameters:
|
||||
* 0 : file descriptor
|
||||
* 1 : stat buf ptr
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int fstat (int fd, struct stat *buf)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
struct gdb_stat gbuf;
|
||||
int ret = 0;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
parameters[1] = (uint32_t) &gbuf;
|
||||
ret = __hosted (HOSTED_FSTAT, parameters);
|
||||
__hosted_from_gdb_stat (&gbuf, buf);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
140
libgloss/csky/io-gdb.c
Normal file
140
libgloss/csky/io-gdb.c
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* hosted io support for GDB's remote fileio protocol
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include "io.h"
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
gdb_mode_t
|
||||
__hosted_to_gdb_mode_t (mode_t m)
|
||||
{
|
||||
gdb_mode_t result = 0;
|
||||
if (m & S_IFREG)
|
||||
result |= GDB_S_IFREG;
|
||||
if (m & S_IFDIR)
|
||||
result |= GDB_S_IFDIR;
|
||||
if (m & S_IRUSR)
|
||||
result |= GDB_S_IRUSR;
|
||||
if (m & S_IWUSR)
|
||||
result |= GDB_S_IWUSR;
|
||||
if (m & S_IXUSR)
|
||||
result |= GDB_S_IXUSR;
|
||||
if (m & S_IRGRP)
|
||||
result |= GDB_S_IRGRP;
|
||||
if (m & S_IWGRP)
|
||||
result |= GDB_S_IWGRP;
|
||||
if (m & S_IXGRP)
|
||||
result |= GDB_S_IXGRP;
|
||||
if (m & S_IROTH)
|
||||
result |= GDB_S_IROTH;
|
||||
if (m & S_IWOTH)
|
||||
result |= GDB_S_IWOTH;
|
||||
if (m & S_IXOTH)
|
||||
result |= GDB_S_IXOTH;
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t
|
||||
__hosted_to_gdb_open_flags (int f)
|
||||
{
|
||||
int32_t result = 0;
|
||||
if (f & O_RDONLY)
|
||||
result |= GDB_O_RDONLY;
|
||||
if (f & O_WRONLY)
|
||||
result |= GDB_O_WRONLY;
|
||||
if (f & O_RDWR)
|
||||
result |= GDB_O_RDWR;
|
||||
if (f & O_APPEND)
|
||||
result |= GDB_O_APPEND;
|
||||
if (f & O_CREAT)
|
||||
result |= GDB_O_CREAT;
|
||||
if (f & O_TRUNC)
|
||||
result |= GDB_O_TRUNC;
|
||||
if (f & O_EXCL)
|
||||
result |= GDB_O_EXCL;
|
||||
return result;
|
||||
}
|
||||
|
||||
int32_t
|
||||
__hosted_to_gdb_lseek_flags (int f)
|
||||
{
|
||||
if (f == SEEK_CUR)
|
||||
return GDB_SEEK_CUR;
|
||||
else if (f == SEEK_END)
|
||||
return GDB_SEEK_END;
|
||||
else
|
||||
return GDB_SEEK_SET;
|
||||
}
|
||||
|
||||
void
|
||||
__hosted_from_gdb_stat (const struct gdb_stat *gs,
|
||||
struct stat *s)
|
||||
{
|
||||
s->st_dev = gs->st_dev;
|
||||
s->st_ino = gs->st_ino;
|
||||
s->st_mode = gs->st_mode;
|
||||
s->st_nlink = gs->st_nlink;
|
||||
s->st_uid = gs->st_uid;
|
||||
s->st_gid = gs->st_gid;
|
||||
s->st_rdev = gs->st_rdev;
|
||||
s->st_size = gs->st_size;
|
||||
s->st_blksize = gs->st_blksize;
|
||||
s->st_blocks = gs->st_blocks;
|
||||
s->st_atim.tv_sec = gs->st_atim;
|
||||
s->st_mtim.tv_sec = gs->st_mtim;
|
||||
s->st_ctim.tv_sec = gs->st_ctim;
|
||||
}
|
||||
|
||||
void
|
||||
__hosted_from_gdb_timeval (const struct gdb_timeval *gt,
|
||||
struct timeval *t)
|
||||
{
|
||||
t->tv_sec = gt->tv_sec;
|
||||
t->tv_usec = gt->tv_usec;
|
||||
}
|
||||
|
||||
int
|
||||
__hosted_from_gdb_errno (int32_t err)
|
||||
{
|
||||
switch (err)
|
||||
{
|
||||
case 0: return 0;
|
||||
case GDB_EPERM: return EPERM;
|
||||
case GDB_ENOENT: return ENOENT;
|
||||
case GDB_EINTR: return EINTR;
|
||||
case GDB_EBADF: return EBADF;
|
||||
case GDB_EACCES: return EACCES;
|
||||
case GDB_EFAULT: return EFAULT;
|
||||
case GDB_EBUSY: return EBUSY;
|
||||
case GDB_EEXIST: return EEXIST;
|
||||
case GDB_ENODEV: return ENODEV;
|
||||
case GDB_ENOTDIR: return ENOTDIR;
|
||||
case GDB_EISDIR: return EISDIR;
|
||||
case GDB_EINVAL: return EINVAL;
|
||||
case GDB_ENFILE: return ENFILE;
|
||||
case GDB_EMFILE: return EMFILE;
|
||||
case GDB_EFBIG: return EFBIG;
|
||||
case GDB_ENOSPC: return ENOSPC;
|
||||
case GDB_ESPIPE: return ESPIPE;
|
||||
case GDB_EROFS: return EROFS;
|
||||
case GDB_ENAMETOOLONG: return ENAMETOOLONG;
|
||||
case GDB_EUNKNOWN:
|
||||
default:
|
||||
return EIO;
|
||||
}
|
||||
}
|
||||
|
55
libgloss/csky/io-gettimeofday.c
Normal file
55
libgloss/csky/io-gettimeofday.c
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* io-gettimeofday.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#define IO gettimeofday
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* gettimeofday -- get the current time
|
||||
* input parameters:
|
||||
* 0 : timeval ptr
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int gettimeofday (struct timeval *tv, void *tzvp)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
struct gdb_timeval gtv;
|
||||
struct timezone *tz = tzvp;
|
||||
int ret = 0;
|
||||
if (!tv)
|
||||
return 0;
|
||||
if (tz)
|
||||
{
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
parameters[0] = (uint32_t) >v;
|
||||
parameters[1] = NULL;
|
||||
ret = __hosted (HOSTED_GETTIMEOFDAY, parameters);
|
||||
__hosted_from_gdb_timeval (>v, tv);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
43
libgloss/csky/io-isatty.c
Normal file
43
libgloss/csky/io-isatty.c
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* io-isatty.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO isatty
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* isatty -- check if fd is a terminal
|
||||
* input parameters:
|
||||
* 0 : file descriptor
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int isatty (int fd)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
int ret;
|
||||
ret = __hosted (HOSTED_ISATTY, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
49
libgloss/csky/io-lseek.c
Normal file
49
libgloss/csky/io-lseek.c
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* io-lseek.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO lseek
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* lseek -- reposition a file descriptor
|
||||
* input parameters:
|
||||
* 0 : file descriptor
|
||||
* 1 : offset
|
||||
* 2 : seek flag
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
off_t lseek (int fd, off_t offset, int whence)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
parameters[1] = (uint32_t) offset;
|
||||
parameters[2] = __hosted_to_gdb_lseek_flags (whence);
|
||||
ret = __hosted (HOSTED_LSEEK, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
62
libgloss/csky/io-open.c
Normal file
62
libgloss/csky/io-open.c
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* io-open.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#define IO open
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* open -- Open a file.
|
||||
* input parameters:
|
||||
* 0 : fname ptr
|
||||
* 1 : fname length
|
||||
* 2 : flags
|
||||
* 3 : mode
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int open (const char *fname, int flags, ...)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret;
|
||||
parameters[0] = (uint32_t) fname;
|
||||
parameters[1] = strlen (fname);
|
||||
parameters[2] = __hosted_to_gdb_open_flags (flags);
|
||||
if (flags & O_CREAT)
|
||||
{
|
||||
va_list ap;
|
||||
va_start (ap, flags);
|
||||
parameters[3] = __hosted_to_gdb_mode_t (va_arg (ap, mode_t));
|
||||
va_end (ap);
|
||||
}
|
||||
else
|
||||
parameters[3] = 0;
|
||||
ret =__hosted (HOSTED_OPEN, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
48
libgloss/csky/io-read.c
Normal file
48
libgloss/csky/io-read.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* semi-read.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO read
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* read -- read from a file descriptor
|
||||
* input parameters:
|
||||
* 0 : file descriptor
|
||||
* 1 : buf ptr
|
||||
* 2 : count
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
ssize_t read (int fd, void *buf, size_t count)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
parameters[1] = (uint32_t) buf;
|
||||
parameters[2] = (uint32_t) count;
|
||||
ret = __hosted (HOSTED_READ, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
51
libgloss/csky/io-rename.c
Normal file
51
libgloss/csky/io-rename.c
Normal file
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* io-rename.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#define IO rename
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* rename -- rename a file
|
||||
* input parameters:
|
||||
* 0 : oldname ptr
|
||||
* 1 : oldname length
|
||||
* 2 : newname ptr
|
||||
* 3 : newname length
|
||||
* output parameters:
|
||||
* 0 : result
|
||||
* 1 : errno
|
||||
*/
|
||||
|
||||
int _rename (const char *oldpath, const char *newpath)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret;
|
||||
parameters[0] = (uint32_t) oldpath;
|
||||
parameters[1] = (uint32_t) strlen (oldpath);
|
||||
parameters[2] = (uint32_t) newpath;
|
||||
parameters[3] = (uint32_t) strlen (newpath);
|
||||
ret = __hosted (HOSTED_RENAME, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
22
libgloss/csky/io-semi.S
Normal file
22
libgloss/csky/io-semi.S
Normal file
@ -0,0 +1,22 @@
|
||||
/* Copyright (c) 2020 C-SKY Microsystems All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the FreeBSD 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.
|
||||
*/
|
||||
|
||||
/* int __hosted (int sys_operate, int *args); */
|
||||
.text
|
||||
.global __hosted
|
||||
.type __hosted, @function
|
||||
.align 2
|
||||
|
||||
__hosted:
|
||||
nop
|
||||
bkpt
|
||||
.long 0x7fff7fff
|
||||
rts
|
54
libgloss/csky/io-stat.c
Normal file
54
libgloss/csky/io-stat.c
Normal file
@ -0,0 +1,54 @@
|
||||
/*
|
||||
* io-stat.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO stat
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* stat -- get file information
|
||||
* input parameters:
|
||||
* 0 : filename ptr
|
||||
* 1 : filename length
|
||||
* 2 : stat buf ptr
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
|
||||
int stat (const char *__restrict filename, struct stat *__restrict buf)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
struct gdb_stat gbuf;
|
||||
int ret;
|
||||
parameters[0] = (uint32_t) filename;
|
||||
parameters[1] = (uint32_t) strlen (filename);
|
||||
parameters[2] = (uint32_t) &gbuf;
|
||||
ret = __hosted (HOSTED_STAT, parameters);
|
||||
__hosted_from_gdb_stat (&gbuf, buf);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
62
libgloss/csky/io-system.c
Normal file
62
libgloss/csky/io-system.c
Normal file
@ -0,0 +1,62 @@
|
||||
/*
|
||||
* io-system.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <sys/wait.h>
|
||||
#define IO _system
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* system: execute command on (remote) host
|
||||
* input parameters:
|
||||
* 0 : command ptr
|
||||
* 1 : command length
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int _system (const char *command)
|
||||
{
|
||||
#if HOSTED
|
||||
int e;
|
||||
gdb_parambuf_t parameters;
|
||||
|
||||
parameters[0] = (uint32_t) command;
|
||||
parameters[1] = command ? (uint32_t) strlen (command) : 0;
|
||||
e = __hosted (HOSTED_SYSTEM, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
if (e >= 0 && command)
|
||||
{
|
||||
/* We have to convert e, an exit status to the encoded status of
|
||||
the command. To avoid hard coding the exit status, we simply
|
||||
loop until we find the right position. */
|
||||
int exit_code;
|
||||
|
||||
for (exit_code = e; e && WEXITSTATUS (e) != exit_code; e <<= 1)
|
||||
continue;
|
||||
}
|
||||
|
||||
return e;
|
||||
#else
|
||||
if (!command)
|
||||
return 0;
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
44
libgloss/csky/io-time.c
Normal file
44
libgloss/csky/io-time.c
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* io-time.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <errno.h>
|
||||
#define IO time
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* time -- get the current time
|
||||
* input parameters:
|
||||
* 0 : timeval ptr
|
||||
* return:
|
||||
* tv_sec if success. Otherwise -1.
|
||||
*/
|
||||
|
||||
time_t time (time_t *t)
|
||||
{
|
||||
#if HOSTED
|
||||
struct timeval tv;
|
||||
|
||||
if (gettimeofday (&tv, NULL))
|
||||
return -1;
|
||||
if (t)
|
||||
*t = tv.tv_sec;
|
||||
return tv.tv_sec;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
47
libgloss/csky/io-unlink.c
Normal file
47
libgloss/csky/io-unlink.c
Normal file
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* io-unlink.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#define IO unlink
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* unlink -- unlink (delete) a file
|
||||
* input parameters:
|
||||
* 0 : filename ptr
|
||||
* 1 : filename length
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
int unlink (const char *path)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret;
|
||||
parameters[0] = (uint32_t) path;
|
||||
parameters[1] = (uint32_t) strlen (path) + 1;
|
||||
ret = __hosted (HOSTED_UNLINK, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
48
libgloss/csky/io-write.c
Normal file
48
libgloss/csky/io-write.c
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* io-write.c --
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#define IO write
|
||||
#include "io.h"
|
||||
|
||||
/*
|
||||
* write -- write to a file descriptor
|
||||
* input parameters:
|
||||
* 0 : file descriptor
|
||||
* 1 : buf ptr
|
||||
* 2 : count
|
||||
* output parameters:
|
||||
* 0 : errno
|
||||
* result : r0
|
||||
*/
|
||||
|
||||
ssize_t write (int fd, const void *buf, size_t count)
|
||||
{
|
||||
#if HOSTED
|
||||
gdb_parambuf_t parameters;
|
||||
int ret = 0;
|
||||
parameters[0] = (uint32_t) fd;
|
||||
parameters[1] = (uint32_t) buf;
|
||||
parameters[2] = (uint32_t) count;
|
||||
ret = __hosted (HOSTED_WRITE, parameters);
|
||||
errno = __hosted_from_gdb_errno (parameters[0]);
|
||||
return ret;
|
||||
#else
|
||||
errno = ENOSYS;
|
||||
return -1;
|
||||
#endif
|
||||
}
|
154
libgloss/csky/io.h
Normal file
154
libgloss/csky/io.h
Normal file
@ -0,0 +1,154 @@
|
||||
/*
|
||||
* hosted & unhosted io support.
|
||||
*
|
||||
* Copyright (c) 2006 CodeSourcery Inc
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
#if HOSTED
|
||||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#define HOSTED_EXIT 0
|
||||
#define HOSTED_INIT_SIM 1
|
||||
#define HOSTED_OPEN 2
|
||||
#define HOSTED_CLOSE 3
|
||||
#define HOSTED_READ 4
|
||||
#define HOSTED_WRITE 5
|
||||
#define HOSTED_LSEEK 6
|
||||
#define HOSTED_RENAME 7
|
||||
#define HOSTED_UNLINK 8
|
||||
#define HOSTED_STAT 9
|
||||
#define HOSTED_FSTAT 10
|
||||
#define HOSTED_GETTIMEOFDAY 11
|
||||
#define HOSTED_ISATTY 12
|
||||
#define HOSTED_SYSTEM 13
|
||||
|
||||
/* This function is provided by the board's BSP, because the precise
|
||||
mechanism of informing gdb is board specific. */
|
||||
extern int __io_hosted (int func, void *args);
|
||||
|
||||
/* Protocol specific representation of datatypes, as specified in D.9.11
|
||||
* of the GDB manual. */
|
||||
|
||||
typedef uint32_t gdb_mode_t;
|
||||
typedef uint32_t gdb_time_t;
|
||||
|
||||
struct gdb_stat {
|
||||
uint32_t st_dev; /* device */
|
||||
uint32_t st_ino; /* inode */
|
||||
gdb_mode_t st_mode; /* protection */
|
||||
uint32_t st_nlink; /* number of hard links */
|
||||
uint32_t st_uid; /* user ID of owner */
|
||||
uint32_t st_gid; /* group ID of owner */
|
||||
uint32_t st_rdev; /* device type (if inode device) */
|
||||
uint64_t st_size; /* total size, in bytes */
|
||||
uint64_t st_blksize; /* blocksize for filesystem I/O */
|
||||
uint64_t st_blocks; /* number of blocks allocated */
|
||||
gdb_time_t st_atim; /* time of last access */
|
||||
gdb_time_t st_mtim; /* time of last modification */
|
||||
gdb_time_t st_ctim; /* time of last change */
|
||||
};
|
||||
|
||||
struct gdb_timeval {
|
||||
gdb_time_t tv_sec; /* second */
|
||||
uint64_t tv_usec; /* microsecond */
|
||||
};
|
||||
|
||||
|
||||
/* Parameters are passed between the library and the debugging stub
|
||||
* in a fixed-size buffer.
|
||||
*/
|
||||
|
||||
typedef uint32_t gdb_parambuf_t[4];
|
||||
|
||||
/* open flags */
|
||||
|
||||
#define GDB_O_RDONLY 0x0
|
||||
#define GDB_O_WRONLY 0x1
|
||||
#define GDB_O_RDWR 0x2
|
||||
#define GDB_O_APPEND 0x8
|
||||
#define GDB_O_CREAT 0x200
|
||||
#define GDB_O_TRUNC 0x400
|
||||
#define GDB_O_EXCL 0x800
|
||||
|
||||
/* mode_t values */
|
||||
|
||||
#define GDB_S_IFREG 0100000
|
||||
#define GDB_S_IFDIR 040000
|
||||
#define GDB_S_IRUSR 0400
|
||||
#define GDB_S_IWUSR 0200
|
||||
#define GDB_S_IXUSR 0100
|
||||
#define GDB_S_IRGRP 040
|
||||
#define GDB_S_IWGRP 020
|
||||
#define GDB_S_IXGRP 010
|
||||
#define GDB_S_IROTH 04
|
||||
#define GDB_S_IWOTH 02
|
||||
#define GDB_S_IXOTH 01
|
||||
|
||||
/* errno values */
|
||||
|
||||
#define GDB_EPERM 1
|
||||
#define GDB_ENOENT 2
|
||||
#define GDB_EINTR 4
|
||||
#define GDB_EBADF 9
|
||||
#define GDB_EACCES 13
|
||||
#define GDB_EFAULT 14
|
||||
#define GDB_EBUSY 16
|
||||
#define GDB_EEXIST 17
|
||||
#define GDB_ENODEV 19
|
||||
#define GDB_ENOTDIR 20
|
||||
#define GDB_EISDIR 21
|
||||
#define GDB_EINVAL 22
|
||||
#define GDB_ENFILE 23
|
||||
#define GDB_EMFILE 24
|
||||
#define GDB_EFBIG 27
|
||||
#define GDB_ENOSPC 28
|
||||
#define GDB_ESPIPE 29
|
||||
#define GDB_EROFS 30
|
||||
#define GDB_ENAMETOOLONG 91
|
||||
#define GDB_EUNKNOWN 9999
|
||||
|
||||
/* lseek flags */
|
||||
|
||||
#define GDB_SEEK_SET 0
|
||||
#define GDB_SEEK_CUR 1
|
||||
#define GDB_SEEK_END 2
|
||||
|
||||
|
||||
/* conversion functions */
|
||||
|
||||
extern gdb_mode_t __hosted_to_gdb_mode_t (mode_t m);
|
||||
extern int32_t __hosted_to_gdb_open_flags (int f);
|
||||
extern int32_t __hosted_to_gdb_lseek_flags (int f);
|
||||
|
||||
extern void __hosted_from_gdb_stat (const struct gdb_stat *gs,
|
||||
struct stat *s);
|
||||
extern void __hosted_from_gdb_timeval (const struct gdb_timeval *gt,
|
||||
struct timeval *t);
|
||||
extern int __hosted_from_gdb_errno (int32_t err);
|
||||
extern int __hosted(int32_t operate, uint32_t *args);
|
||||
|
||||
#else
|
||||
#ifdef IO
|
||||
#define IO_NAME_(IO) __hosted_##IO
|
||||
#define IO_NAME(IO) IO_NAME_(IO)
|
||||
#define IO_STRING_(IO) #IO
|
||||
#define IO_STRING(IO) IO_STRING_(IO)
|
||||
/* Emit an object that causes a gnu linker warning. */
|
||||
static const char IO_NAME (IO) []
|
||||
__attribute__ ((section (".gnu.warning"), used)) =
|
||||
"IO function '" IO_STRING (IO) "' used";
|
||||
#endif
|
||||
#endif
|
27
libgloss/csky/kill.c
Normal file
27
libgloss/csky/kill.c
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* kill.c
|
||||
*
|
||||
* Copyright (c) 2018 Mentor Graphics
|
||||
*
|
||||
* The authors hereby grant permission to use, copy, modify, distribute,
|
||||
* and license this software and its documentation for any purpose, provided
|
||||
* that existing copyright notices are retained in all copies and that this
|
||||
* notice is included verbatim in any distributions. No written agreement,
|
||||
* license, or royalty fee is required for any of the authorized uses.
|
||||
* Modifications to this software may be copyrighted by their authors
|
||||
* and need not follow the licensing terms described here, provided that
|
||||
* the new terms are clearly indicated on the first page of each file where
|
||||
* they apply.
|
||||
*/
|
||||
|
||||
/* Minimal implementation of kill for a target system without processes. */
|
||||
|
||||
extern void _exit (int);
|
||||
|
||||
int
|
||||
kill (int pid, int sig)
|
||||
{
|
||||
if (pid == 1)
|
||||
_exit (sig);
|
||||
return 0;
|
||||
}
|
37
libgloss/csky/sbrk.c
Normal file
37
libgloss/csky/sbrk.c
Normal file
@ -0,0 +1,37 @@
|
||||
/* Copyright (c) 2020 C-SKY Microsystems All rights reserved.
|
||||
|
||||
This copyrighted material is made available to anyone wishing to use,
|
||||
modify, copy, or redistribute it subject to the terms and conditions
|
||||
of the FreeBSD 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.
|
||||
*/
|
||||
|
||||
#include <errno.h>
|
||||
/*
|
||||
+ * sbrk -- changes heap size size. Get nbytes more
|
||||
+ * RAM. We just increment a pointer in what's
|
||||
+ * left of memory on the board.
|
||||
+ */
|
||||
|
||||
/* Provided by the linker script. */
|
||||
extern char __heap_start[] __attribute__ ((aligned (8)));
|
||||
extern char __heap_end[] __attribute__ ((aligned (8)));
|
||||
|
||||
void *
|
||||
sbrk (int nbytes)
|
||||
{
|
||||
static char *heap = __heap_start;
|
||||
char *base = heap;
|
||||
char *new_heap = heap + nbytes;
|
||||
|
||||
if (nbytes < 0 || new_heap > __heap_end)
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return (void *)-1;
|
||||
}
|
||||
heap = new_heap;
|
||||
return base;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user