2004-10-05 Tomer Levi <Tomer.Levi@nsc.com>

* configure.in: Support crx-*-*.
        * configure: regenerate.
        * crx/_exit.c: New file.
        * crx/_getenv.c: Ditto.
        * crx/_rename: Ditto.
        * crx/close.c: Ditto.
        * crx/configure.in: Ditto.
        * crx/crti.S: Ditto.
        * crx/crtn.S: Ditto.
        * crx/crt0.S: Ditto.
        * crx/dvz_hndl.c: Ditto.
        * crx/flg_hndl.c: Ditto.
        * crx/fstat.c: Ditto.
        * crx/getpid.c: Ditto.
        * crx/iad_hndl.c: Ditto.
        * crx/intable.c: Ditto.
        * crx/isatty.c: Ditto.
        * crx/kill.c: Ditto.
        * crx/lseek.c: Ditto.
        * crx/Makefile.in: Ditto.
        * crx/open.c: Ditto.
        * crx/putnum.c: Ditto.
        * crx/read.c: Ditto.
        * crx/sbrk.c: Ditto.
        * crx/sim.ld: Ditto.
        * crx/stat.c: Ditto.
        * crx/svc_hndl.c: Ditto.
        * crx/time.c: Ditto.
        * crx/und_hndl.c: Ditto.
        * crx/unlink.c: Ditto.
        * crx/write.c: Ditto.
This commit is contained in:
Jeff Johnston 2004-10-05 20:00:53 +00:00
parent 1185687a7b
commit 49a8b8f05c
33 changed files with 2485 additions and 8 deletions

View File

@ -1,4 +1,37 @@
2004-01-01 Paul Brook <paul@codesourcery.com>
2004-10-05 Tomer Levi <Tomer.Levi@nsc.com>
* configure.in: Support crx-*-*.
* configure: regenerate.
* crx/_exit.c: New file.
* crx/_getenv.c: Ditto.
* crx/_rename: Ditto.
* crx/close.c: Ditto.
* crx/configure.in: Ditto.
* crx/crti.S: Ditto.
* crx/crtn.S: Ditto.
* crx/crt0.S: Ditto.
* crx/dvz_hndl.c: Ditto.
* crx/flg_hndl.c: Ditto.
* crx/fstat.c: Ditto.
* crx/getpid.c: Ditto.
* crx/iad_hndl.c: Ditto.
* crx/intable.c: Ditto.
* crx/isatty.c: Ditto.
* crx/kill.c: Ditto.
* crx/lseek.c: Ditto.
* crx/Makefile.in: Ditto.
* crx/open.c: Ditto.
* crx/putnum.c: Ditto.
* crx/read.c: Ditto.
* crx/sbrk.c: Ditto.
* crx/sim.ld: Ditto.
* crx/stat.c: Ditto.
* crx/svc_hndl.c: Ditto.
* crx/time.c: Ditto.
* crx/und_hndl.c: Ditto.
* crx/unlink.c: Ditto.
* crx/write.c: Ditto.
2004-01-01 Paul Brook <paul@codesourcery.com>
* arm/configure.in: Add *-*-aebi target.
* arm/configure: Regenerate.

17
libgloss/configure vendored
View File

@ -774,6 +774,9 @@ case "${target}" in
mn10300-*-*)
configdirs="${configdirs} mn10300 testsuite"
;;
crx-*-*)
configdirs="${configdirs} crx"
;;
d30v-*-*)
configdirs="${configdirs} d30v testsuite"
;;
@ -821,7 +824,7 @@ subdirs="$configdirs"
# Extract the first word of "gcc", so it can be a program name with args.
set dummy gcc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:825: checking for $ac_word" >&5
echo "configure:828: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -851,7 +854,7 @@ if test -z "$CC"; then
# Extract the first word of "cc", so it can be a program name with args.
set dummy cc; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:855: checking for $ac_word" >&5
echo "configure:858: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -900,7 +903,7 @@ fi
fi
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
echo "configure:904: checking whether we are using GNU C" >&5
echo "configure:907: checking whether we are using GNU C" >&5
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -909,7 +912,7 @@ else
yes;
#endif
EOF
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:913: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:916: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
ac_cv_prog_gcc=yes
else
ac_cv_prog_gcc=no
@ -924,7 +927,7 @@ if test $ac_cv_prog_gcc = yes; then
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
echo "configure:928: checking whether ${CC-cc} accepts -g" >&5
echo "configure:931: checking whether ${CC-cc} accepts -g" >&5
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -956,7 +959,7 @@ AS=${AS-as}
# Extract the first word of "ar", so it can be a program name with args.
set dummy ar; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:960: checking for $ac_word" >&5
echo "configure:963: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else
@ -990,7 +993,7 @@ LD=${LD-ld}
# Extract the first word of "ranlib", so it can be a program name with args.
set dummy ranlib; ac_word=$2
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
echo "configure:994: checking for $ac_word" >&5
echo "configure:997: checking for $ac_word" >&5
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
else

View File

@ -85,6 +85,9 @@ case "${target}" in
mn10300-*-*)
configdirs="${configdirs} mn10300 testsuite"
;;
crx-*-*)
configdirs="${configdirs} crx"
;;
d30v-*-*)
configdirs="${configdirs} d30v testsuite"
;;

156
libgloss/crx/Makefile.in Normal file
View File

@ -0,0 +1,156 @@
#
#
DESTDIR =
VPATH = @srcdir@ @srcdir@/..
srcdir = @srcdir@
objdir = .
srcroot = $(srcdir)/../..
objroot = $(objdir)/../..
prefix = @prefix@
exec_prefix = @exec_prefix@
host_alias = @host_alias@
target_alias = @target_alias@
bindir = @bindir@
libdir = @libdir@
tooldir = $(exec_prefix)/$(target_alias)
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_DATA = @INSTALL_DATA@
# Multilib support variables.
# TOP is used instead of MULTI{BUILD,SRC}TOP.
MULTIDIRS =
MULTISUBDIR =
SHELL = /bin/sh
CC = @CC@
AS = @AS@
AR = @AR@
LD = @LD@
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`
# Here is all of the handlers stuff
H_SCRIPTS =
H_BSP = libh.a
H_OBJS = intable.o dvz_hndl.o flg_hndl.o iad_hndl.o svc_hndl.o und_hndl.o
H_TEST = hndl-test
H_INSTALL = install-hndl
# Here is all of the simulator stuff
SIM_SCRIPTS = sim.ld
SIM_BSP = libsim.a
SIM_OBJS = _exit.o close.o _getenv.o lseek.o open.o read.o \
_rename.o sbrk.o time.o unlink.o write.o \
stat.o putnum.o kill.o getpid.o isatty.o fstat.o
SIM_TEST = sim-test
SIM_INSTALL = install-sim
# Here is all of the CRT stuff
CRT = crti.o crtn.o crt0.o
CRT_INSTALL = install-crt
# Host specific makefile fragment comes in here.
@host_makefile_frag@
#
# build a test program for each target board. Just trying to get
# it to link is a good test, so we ignore all the errors for now.
#
all: ${CRT} ${SIM_BSP} ${H_BSP}
#
# here's where we build the board support packages for each target
#
${H_BSP}: ${H_OBJS}
${AR} ${ARFLAGS} ${H_BSP} ${H_OBJS}
${RANLIB} ${H_BSP}
${SIM_BSP}: ${SIM_OBJS}
${AR} ${ARFLAGS} ${SIM_BSP} ${SIM_OBJS}
${RANLIB} ${SIM_BSP}
#
# here's where we build the test programs for each target
#
.PHONY: test
test: ${SIM_TEST} ${H_TEST}
hndl-test: hndl-test.x hndl-test.dis
hndl-test.x: test.o ${H_BSP}
${CC} ${LDFLAGS_FOR_TARGET} -L${objdir} \
test.o \
-o hndl-test.x ${LIBS_FOR_TARGET} -lc ${H_BSP} -Wl,-T${SIM_SCRIPTS}
hndl-test.dis: hndl-test.x
${OBJDUMP} -d hndl-test.x > hndl-test.dis
sim-test: sim-test.x sim-test.dis
sim-test.x: test.o ${SIM_BSP}
${CC} ${LDFLAGS_FOR_TARGET} -L${objdir} \
test.o \
-o sim-test.x ${LIBS_FOR_TARGET} -lc ${SIM_BSP} -Wl,-T${SIM_SCRIPTS}
sim-test.dis: sim-test.x
${OBJDUMP} -d sim-test.x > sim-test.dis
#
#
#
.c.S:
${CC} ${CFLAGS_FOR_TARGET} -c $<
clean mostlyclean:
rm -f a.out core *.i *.o *-test *.srec *.dis *.x $(SIM_BSP) $(H_BSP)
distclean maintainer-clean realclean: clean
rm -f Makefile config.status *~
.PHONY: install info install-info clean-info
install: ${CRT_INSTALL} ${SIM_INSTALL} ${H_INSTALL}
install-crt:
set -e; for x in ${CRT} ; do\
${INSTALL_DATA} $$x $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; \
done
install-sim:
for x in ${SIM_BSP} ; do\
${INSTALL_PROGRAM} $${x} $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; \
done
for x in ${SIM_SCRIPTS}; do\
${INSTALL_DATA} ${srcdir}/$${x} $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; \
done
install-hndl:
for x in ${H_BSP}; do\
${INSTALL_PROGRAM} $${x} $(DESTDIR)${tooldir}/lib${MULTISUBDIR}/$$x; \
done
doc:
info:
install-info:
clean-info:
Makefile: Makefile.in config.status @host_makefile_frag_path@
$(SHELL) config.status
config.status: configure
$(SHELL) config.status --recheck

23
libgloss/crx/_exit.c Normal file
View File

@ -0,0 +1,23 @@
/* _exit.c -- Implementation of the low-level _exit() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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 <sys/syscall.h>
/* Returns control to the debugger. */
void _exit (int stat)
{
HOST_SERVICE (SVC_EOP);
}

36
libgloss/crx/_getenv.c Normal file
View File

@ -0,0 +1,36 @@
/* _getenv.c -- Implementation of the low-level _getenv() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
#include <stdlib.h>
register char *R2 __asm__("r2");
register char *R3 __asm__("r3");
char * _getenv (const char *name)
{
char *x;
char *y;
x = R2;
y = (char *) calloc (256, 1);
R3 = y;
R2 = x;
HOST_SERVICE (SVC_GETENV);
}

21
libgloss/crx/_rename.c Normal file
View File

@ -0,0 +1,21 @@
/* _rename.c -- Implementation of the low-level rename() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
int _rename (char *from, char *to)
{
HOST_SERVICE (SVC_RENAME);
}

21
libgloss/crx/close.c Normal file
View File

@ -0,0 +1,21 @@
/* close.c -- Implementation of the low-level close() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
int close (int fd)
{
HOST_SERVICE (SVC_CLOSE);
}

1228
libgloss/crx/configure vendored Executable file

File diff suppressed because it is too large Load Diff

75
libgloss/crx/configure.in Normal file
View File

@ -0,0 +1,75 @@
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.5)dnl
AC_INIT(intable.c)
AC_CANONICAL_SYSTEM
AC_ARG_PROGRAM
if test "$srcdir" = "." ; then
mdir=`echo "${with_multisubdir}/" \
| sed -e 's,\([[^/]][[^/]]*\),..,g' -e 's,^/$,,'`
AC_CONFIG_AUX_DIR(${mdir}../../..)
else
AC_CONFIG_AUX_DIR(${srcdir}/../..)
fi
AC_PROG_INSTALL
# FIXME: We temporarily define our own version of AC_PROG_CC. This is
# copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We
# are probably using a cross compiler, which will not be able to fully
# link an executable. This should really be fixed in autoconf
# itself.
AC_DEFUN(LIB_AC_PROG_CC,
[AC_BEFORE([$0], [AC_PROG_CPP])dnl
AC_CHECK_PROG(CC, gcc, gcc)
if test -z "$CC"; then
AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc)
test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH])
fi
AC_PROG_CC_GNU
if test $ac_cv_prog_gcc = yes; then
GCC=yes
dnl Check whether -g works, even if CFLAGS is set, in case the package
dnl plays around with CFLAGS (such as to build both debugging and
dnl normal versions of a library), tasteless as that idea is.
ac_test_CFLAGS="${CFLAGS+set}"
ac_save_CFLAGS="$CFLAGS"
CFLAGS=
AC_PROG_CC_G
if test "$ac_test_CFLAGS" = set; then
CFLAGS="$ac_save_CFLAGS"
elif test $ac_cv_prog_cc_g = yes; then
CFLAGS="-g -O2"
else
CFLAGS="-O2"
fi
else
GCC=
test "${CFLAGS+set}" = set || CFLAGS="-g"
fi
])
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
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_OUTPUT(Makefile)

93
libgloss/crx/crt0.S Normal file
View File

@ -0,0 +1,93 @@
##############################################################################
# crt0.S -- CRX default start-up routine #
# #
# Copyright (c) 2004 National Semiconductor Corporation #
# #
# 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. #
# #
# This is the start routine of your CRX program. #
# It is linked with your application automatically. You can use #
# this routine as a template and modify it to your needs, yet this #
# file must be supplied for the compiler. #
# It is assumed that the following symbols are defined in your linker #
# script: __STACK_START, __ISTACK_START, __DATA_START, __DATA_END, #
# __DATA_IMAGE_START, __BSS_START, __BSS_END. #
##############################################################################
.text
.align 4
.globl _main
.globl _start
.globl _atexit
.globl _exit
.globl __dispatch_table
_start:
#----------------------------------------------------------------------------#
# Initialize the stack pointers. The constants __STACK_START and #
# __ISTACK_START should be defined in the linker script. #
movd $__STACK_START, sp
movd $__ISTACK_START, r0
mtpr r0, isp
#----------------------------------------------------------------------------#
# Initialize the default sections according to the linker script. #
movd $__DATA_END, r4
subd $__DATA_START, r4
movd $__DATA_START, r2
movd $__DATA_IMAGE_START, r3
bal ra, _memcpy
movd $__BSS_END, r4
subd $__BSS_START, r4
movd $__BSS_START, r2
movd $0, r3
bal ra, _memset
#----------------------------------------------------------------------------#
# Initialize the intbase (pointer to the dispatch table). #
movd $__dispatch_table, r0
mtpr r0, intbase
#----------------------------------------------------------------------------#
# Handle global and static constructurs execution and setup #
# destructors to be called from exit. #
bal ra, _init
movd $_fini, r2
bal ra, _atexit
#----------------------------------------------------------------------------#
# Here you may add initializations that are specific to your #
# environment. For example: #
# 1. Configure wait states and other BIU parameters in order to get #
# the best performance out of your target (see the specification #
# document). #
# 2. Enable maskable interrupts that should be enabled when your #
# program starts to execute. #
#----------------------------------------------------------------------------#
# Jump to the main function in your application. #
bal ra, _main
#----------------------------------------------------------------------------#
# Upon returning from the main function (if it isn't an infinite loop), #
# jump to the exit function. The exit function is located in the #
# library 'libc.a'. #
movd r0, r2 # _main return value is passed as a
# parameter to exit.
br _exit # returns control to the debugger.

47
libgloss/crx/crti.S Normal file
View File

@ -0,0 +1,47 @@
/* Specialized code needed to support construction and destruction of
file-scope objects in C++ and Java code, and to support exception handling.
Copyright (C) 1999 Free Software Foundation, Inc.
Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, if you link this library with files
compiled with GCC to produce an executable, this does not cause
the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
/*
* This file just supplies function prologues for the .init and .fini
* sections. It is linked in before crtbegin.o.
*/
.file "crti.o"
.ident "GNU C crti.o"
.section .init
.globl _init
.type _init,@function
_init:
push ra
.section .fini
.globl _fini
.type _fini,@function
_fini:
push ra

41
libgloss/crx/crtn.S Normal file
View File

@ -0,0 +1,41 @@
/* Specialized code needed to support construction and destruction of
file-scope objects in C++ and Java code, and to support exception handling.
Copyright (C) 1999 Free Software Foundation, Inc.
Contributed by Charles-Antoine Gauthier (charles.gauthier@iit.nrc.ca).
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING. If not, write to
the Free Software Foundation, 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
/* As a special exception, if you link this library with files
compiled with GCC to produce an executable, this does not cause
the resulting executable to be covered by the GNU General Public License.
This exception does not however invalidate any other reasons why
the executable file might be covered by the GNU General Public License. */
/*
* This file supplies function epilogues for the .init and .fini sections.
* It is linked in after all other files.
*/
.file "crtn.o"
.ident "GNU C crtn.o"
.section .init
popret ra
.section .fini
popret ra

23
libgloss/crx/dvz_hndl.c Normal file
View File

@ -0,0 +1,23 @@
/* dvz_hndl.c -- Implementation of the DVZ trap handler
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
void dvz_handler (void) __attribute__ ((interrupt ()));
void dvz_handler (void)
{
HOST_SERVICE (SVC_DVZ);
}

23
libgloss/crx/flg_hndl.c Normal file
View File

@ -0,0 +1,23 @@
/* flg_hndl.c -- Implementation of the FLG trap handler
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
void flg_handler (void) __attribute__ ((interrupt ()));
void flg_handler (void)
{
HOST_SERVICE (SVC_FLG);
}

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

@ -0,0 +1,30 @@
/* fstat.c -- get status of a file.
*
* Copyright (c) 1995 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.
*/
#include <_ansi.h>
#include <sys/stat.h>
/*
* fstat -- Since we have no file system, we just return an error.
*/
int
_DEFUN (fstat, (fd, buf),
int fd _AND
struct stat *buf)
{
buf->st_mode = S_IFCHR; /* Always pretend to be a tty */
buf->st_blksize = 0;
return (0);
}

26
libgloss/crx/getpid.c Normal file
View File

@ -0,0 +1,26 @@
/* getpid.c -- get the current process id.
*
* Copyright (c) 1995 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.
*/
#include <_ansi.h>
#define __MYPID 1
/*
* getpid -- only one process, so just return 1.
*/
int
_DEFUN (getpid, (),
)
{
return __MYPID;
}

23
libgloss/crx/iad_hndl.c Normal file
View File

@ -0,0 +1,23 @@
/* iad_hndl.c -- Implementation of the IAD trap handler
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
void iad_handler (void) __attribute__ ((interrupt ()));
void iad_handler (void)
{
HOST_SERVICE (SVC_IAD);
}

37
libgloss/crx/intable.c Normal file
View File

@ -0,0 +1,37 @@
/* intable.c -- CompactRISC default dispatch table definition
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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 <sys/libh.h>
void (* const _dispatch_table[32])(void)=
{
NULL,
NULL,
NULL,
NULL,
NULL,
svc_handler,
dvz_handler,
flg_handler,
NULL,
NULL,
und_handler,
NULL,
iad_handler,
NULL,
NULL,
NULL
};

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

@ -0,0 +1,27 @@
/* isatty.c -- chek the terminal device.
*
* Copyright (c) 1995 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.
*/
#include <_ansi.h>
/*
* isatty -- returns 1 if connected to a terminal device,
* returns 0 if not. Since we're hooked up to a
* serial port, we'll say yes _AND return a 1.
*/
int
_DEFUN (isatty, (fd),
int fd)
{
return (1);
}

29
libgloss/crx/kill.c Normal file
View File

@ -0,0 +1,29 @@
/* kill.c -- remove a process.
*
* Copyright (c) 1995 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.
*/
#include <_ansi.h>
#define __MYPID 1
/*
* kill -- go out via exit...
*/
int
_DEFUN (kill, (pid, sig),
int pid _AND
int sig)
{
if(pid == __MYPID)
_exit(sig);
return 0;
}

21
libgloss/crx/lseek.c Normal file
View File

@ -0,0 +1,21 @@
/* lseek.c -- Implementation of the low-level lseek() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
long lseek (int fd, long offset, int whence)
{
HOST_SERVICE (SVC_LSEEK);
}

41
libgloss/crx/open.c Normal file
View File

@ -0,0 +1,41 @@
/* open.c -- Implementation of the low-level open() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
#include <stdarg.h>
int open_aux (char *, int, int);
/* The prototype in <fcntl.h> for open() uses ..., meaning function
* parameters reside on stack, but the debugger expects the parameters
* to reside in registers, thus we call an auxiliary function with
* bounded number of parameters.
*/
int open (char *path, int flags, ...)
{
int mode;
va_list ap;
va_start(ap, flags);
mode = va_arg(ap, int);
open_aux (path, flags, mode);
va_end(ap);
}
int open_aux (char *path, int flags, int mode)
{
HOST_SERVICE (SVC_OPEN);
}

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

@ -0,0 +1,41 @@
/* putnum.c -- put a hex number on the output device.
*
* Copyright (c) 1995 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.
*/
#include <_ansi.h>
/*
* putnum -- print a 32 bit number in hex
*/
void
_DEFUN (putnum, (num),
unsigned int num)
{
char buf[9];
int cnt;
char *ptr;
int digit;
ptr = buf;
for (cnt = 7 ; cnt >= 0 ; cnt--) {
digit = (num >> (cnt * 4)) & 0xf;
if (digit <= 9)
*ptr++ = (char) ('0' + digit);
else
*ptr++ = (char) ('a' - 10 + digit);
}
*ptr = (char) 0;
print (buf);
}

21
libgloss/crx/read.c Normal file
View File

@ -0,0 +1,21 @@
/* read.c -- Implementation of the low-level read() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
int read (int fd, char *buffer, int nbytes)
{
HOST_SERVICE (SVC_READ);
}

56
libgloss/crx/sbrk.c Normal file
View File

@ -0,0 +1,56 @@
/* sbrk.c -- Implementation of the low-level sbrk() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* The authors hereby grant permission to use, copy, modify, distribute,
* and license this software and its documentation for any purpose, provided
* that existing copyright notices are retained in all copies and that this
* notice is included verbatim in any distributions. No written agreement,
* license, or royalty fee is required for any of the authorized uses.
* Modifications to this software may be copyrighted by their authors
* and need not follow the licensing terms described here, provided that
* the new terms are clearly indicated on the first page of each file where
* they apply.
*/
#include <errno.h>
#include <stddef.h> /* where ptrdiff_t is defined */
#include <stdlib.h>
/* Extend heap space by size bytes.
Return start of new space allocated, or -1 for errors
Error cases:
1. Allocation is not within heap range */
void * sbrk (ptrdiff_t size)
{
/*
* The following two memory locations should be defined in the linker script file
*/
extern const char _HEAP_START; /* start of heap */
extern const char _HEAP_MAX; /* end of heap (maximum value of heap_ptr) */
static const char * heap_ptr; /* pointer to head of heap */
const char * old_heap_ptr;
static unsigned char init_sbrk = 0;
/* heap_ptr is initialized to HEAP_START */
if (init_sbrk == 0)
{
heap_ptr = &_HEAP_START;
init_sbrk = 1;
}
old_heap_ptr = heap_ptr;
if ((heap_ptr + size) > &_HEAP_MAX)
{
/* top of heap is bigger than _HEAP_MAX */
errno = ENOMEM;
return (void *) -1;
}
/* success: update heap_ptr and return previous value */
heap_ptr += size;
return (void *)old_heap_ptr;
}

126
libgloss/crx/sim.ld Normal file
View File

@ -0,0 +1,126 @@
/* Example Linker Script for linking NS CRX elf32 files. */
OUTPUT_FORMAT("elf32-crx")
OUTPUT_ARCH(crx)
/*
The libh.a library includes various CR default handlers.
The libsim.a library includes low-level functions, which
are used as an interface to communicate with the simulator.
*/
GROUP(-lc -lsim -lh -lgcc)
/*
The next line forces the entry point (_start in this script)
to be entered in the output file as an undefined symbol.
It is needed in case the entry point is not called explicitly
(which is the usual case) AND is in an archive.
*/
EXTERN(_start)
ENTRY(_start)
/* Define memory regions */
MEMORY
{
rom : ORIGIN = 0x2, LENGTH = 3M
ram : ORIGIN = 4M, LENGTH = 10M
}
SECTIONS
{
.init :
{
__INIT_START = .;
KEEP (*(.init))
__INIT_END = .;
} > rom
.fini :
{
__FINI_START = .;
KEEP (*(.fini))
__FINI_END = .;
} > rom
.jcr :
{
KEEP (*(.jcr))
} > rom
.text :
{
__TEXT_START = .;
*(.text) *(.text.*) *(.gnu.linkonce.t.*)
__TEXT_END = .;
} > rom
.rdata :
{
__RDATA_START = .;
*(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*)
__RDATA_END = .;
} > rom
.ctor ALIGN(4) :
{
__CTOR_START = .;
KEEP (*crtbegin*.o(.ctors))
KEEP (*(EXCLUDE_FILE (*crtend*.o) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
__CTOR_END = .;
} > rom
.dtor ALIGN(4) :
{
__DTOR_START = .;
KEEP (*crtbegin*.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend*.o) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
__DTOR_END = .;
} > rom
.data :
{
__DATA_START = .;
*(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
__DATA_END = .;
} > ram AT > rom
.bss (NOLOAD) :
{
__BSS_START = .;
*(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
__BSS_END = .;
} > ram
/*
You may change the sizes of the following sections to fit the actual
size your program requires.
The heap and stack are aligned to the bus width, as a speed optimization
for accessing data located there.
*/
.heap :
{
. = ALIGN(4);
__HEAP_START = .;
. += 0x2000;
__HEAP_MAX = .;
} > ram
.stack :
{
. = ALIGN(4);
. += 0x6000;
__STACK_START = .;
} > ram
.istack :
{
. = ALIGN(4);
. += 0x100;
__ISTACK_START = .;
} > ram
}
__DATA_IMAGE_START = LOADADDR(.data);

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

@ -0,0 +1,30 @@
/* stat.c -- Get the status of a file.
*
* Copyright (c) 1995 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.
*/
#include <_ansi.h>
#include <sys/stat.h>
#include <errno.h>
/*
* stat -- Since we have no file system, we just return an error.
*/
int
_DEFUN (stat, (path, buf),
const char *path _AND
struct stat *buf)
{
errno = EIO;
return (-1);
}

23
libgloss/crx/svc_hndl.c Normal file
View File

@ -0,0 +1,23 @@
/* svc_hndl.c -- Implementation of the SVC trap handler
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
void svc_handler (void) __attribute__ ((interrupt ()));
void svc_handler (void)
{
HOST_SERVICE (SVC_SVC);
}

55
libgloss/crx/time.c Normal file
View File

@ -0,0 +1,55 @@
/* time.c -- Implementation of the low-level time() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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 <time.h>
#include <errno.h>
#include <sys/time.h>
#include <sys/times.h>
#include <sys/syscall.h>
time_t _Time (time_t *timer)
{
HOST_SERVICE (SVC_TIME);
}
time_t time (time_t *tod)
{
time_t t = _Time (NULL);
if (tod)
*tod = t;
return (t);
}
/* _times -- no clock, so return an error. */
clock_t times (struct tms *buf)
{
errno = EINVAL;
return (-1);
}
/* _gettimeofday -- implement in terms of time. */
int gettimeofday (struct timeval *tv, struct timezone *tz)
{
if (tz)
tz->tz_minuteswest = tz->tz_dsttime = 0;
tv->tv_usec = 0;
tv->tv_sec = time (0);
return 0;
}

23
libgloss/crx/und_hndl.c Normal file
View File

@ -0,0 +1,23 @@
/* und_hndl.c -- Implementation of the UND trap handler
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
void und_handler (void) __attribute__ ((interrupt ()));
void und_handler (void)
{
HOST_SERVICE (SVC_UND);
}

21
libgloss/crx/unlink.c Normal file
View File

@ -0,0 +1,21 @@
/* unlink.c -- Implementation of the low-level unlink() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
int unlink (char *path)
{
HOST_SERVICE (SVC_UNLINK);
}

21
libgloss/crx/write.c Normal file
View File

@ -0,0 +1,21 @@
/* write.c -- Implementation of the low-level write() routine
*
* Copyright (c) 2004 National Semiconductor Corporation
*
* 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/syscall.h>
int write (int fd, char *buffer, int nbytes)
{
HOST_SERVICE (SVC_WRITE);
}