Index: newlib/libgloss/configure.in diff -c newlib/libgloss/configure.in:1.1.1.2 newlib/libgloss/configure.in:1.1.1.1.2.2 *** newlib/libgloss/configure.in:1.1.1.2 Fri Sep 17 15:40:33 2004 --- newlib/libgloss/configure.in Fri Sep 17 15:57:30 2004 *************** *** 85,90 **** --- 85,93 ---- mn10300-*-*) configdirs="${configdirs} mn10300 testsuite" ;; + crx-*-*) + configdirs="${configdirs} crx" + ;; d30v-*-*) configdirs="${configdirs} d30v testsuite" ;; Index: newlib/libgloss/crx/Makefile.in diff -c /dev/null newlib/libgloss/crx/Makefile.in:1.1.2.4 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/Makefile.in Mon Sep 27 13:44:02 2004 *************** *** 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 + 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 Index: newlib/libgloss/crx/_exit.c diff -c /dev/null newlib/libgloss/crx/_exit.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/_exit.c Fri Oct 1 14:02:13 2004 *************** *** 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 + #include + + /* Returns control to the debugger. */ + void _exit (int stat) + { + HOST_SERVICE (SVC_EOP); + } Index: newlib/libgloss/crx/_getenv.c diff -c /dev/null newlib/libgloss/crx/_getenv.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/_getenv.c Fri Oct 1 14:02:13 2004 *************** *** 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 + #include + + 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); + } + Index: newlib/libgloss/crx/_rename.c diff -c /dev/null newlib/libgloss/crx/_rename.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/_rename.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + int _rename (char *from, char *to) + { + HOST_SERVICE (SVC_RENAME); + } Index: newlib/libgloss/crx/close.c diff -c /dev/null newlib/libgloss/crx/close.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/close.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + int close (int fd) + { + HOST_SERVICE (SVC_CLOSE); + } Index: newlib/libgloss/crx/configure.in diff -c /dev/null newlib/libgloss/crx/configure.in:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/configure.in Wed Sep 1 15:52:30 2004 *************** *** 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) Index: newlib/libgloss/crx/crti.S diff -c /dev/null newlib/libgloss/crx/crti.S:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/crti.S Wed Sep 15 17:19:36 2004 *************** *** 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 + Index: newlib/libgloss/crx/crtn.S diff -c /dev/null newlib/libgloss/crx/crtn.S:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/crtn.S Wed Sep 15 17:19:36 2004 *************** *** 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 Index: newlib/libgloss/crx/dvz_hndl.c diff -c /dev/null newlib/libgloss/crx/dvz_hndl.c:1.1.2.4 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/dvz_hndl.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + void dvz_handler (void) __attribute__ ((interrupt ())); + + void dvz_handler (void) + { + HOST_SERVICE (SVC_DVZ); + } Index: newlib/libgloss/crx/flg_hndl.c diff -c /dev/null newlib/libgloss/crx/flg_hndl.c:1.1.2.4 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/flg_hndl.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + void flg_handler (void) __attribute__ ((interrupt ())); + + void flg_handler (void) + { + HOST_SERVICE (SVC_FLG); + } Index: newlib/libgloss/crx/fstat.c diff -c /dev/null newlib/libgloss/crx/fstat.c:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/fstat.c Mon Sep 27 13:38:02 2004 *************** *** 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 + + /* + * 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); + } Index: newlib/libgloss/crx/getpid.c diff -c /dev/null newlib/libgloss/crx/getpid.c:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/getpid.c Mon Sep 27 13:38:02 2004 *************** *** 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; + } Index: newlib/libgloss/crx/iad_hndl.c diff -c /dev/null newlib/libgloss/crx/iad_hndl.c:1.1.2.4 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/iad_hndl.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + void iad_handler (void) __attribute__ ((interrupt ())); + + void iad_handler (void) + { + HOST_SERVICE (SVC_IAD); + } Index: newlib/libgloss/crx/intable.c diff -c /dev/null newlib/libgloss/crx/intable.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/intable.c Fri Oct 1 14:02:13 2004 *************** *** 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 + #include + + 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 + }; Index: newlib/libgloss/crx/isatty.c diff -c /dev/null newlib/libgloss/crx/isatty.c:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/isatty.c Mon Sep 27 13:38:02 2004 *************** *** 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); + } Index: newlib/libgloss/crx/kill.c diff -c /dev/null newlib/libgloss/crx/kill.c:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/kill.c Mon Sep 27 13:38:02 2004 *************** *** 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; + } Index: newlib/libgloss/crx/lseek.c diff -c /dev/null newlib/libgloss/crx/lseek.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/lseek.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + long lseek (int fd, long offset, int whence) + { + HOST_SERVICE (SVC_LSEEK); + } Index: newlib/libgloss/crx/open.c diff -c /dev/null newlib/libgloss/crx/open.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/open.c Fri Oct 1 14:02:13 2004 *************** *** 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 + #include + + int open_aux (char *, int, int); + + /* The prototype in 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); + } + Index: newlib/libgloss/crx/putnum.c diff -c /dev/null newlib/libgloss/crx/putnum.c:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/putnum.c Mon Sep 27 13:38:02 2004 *************** *** 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); + } Index: newlib/libgloss/crx/read.c diff -c /dev/null newlib/libgloss/crx/read.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/read.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + int read (int fd, char *buffer, int nbytes) + { + HOST_SERVICE (SVC_READ); + } Index: newlib/libgloss/crx/sbrk.c diff -c /dev/null newlib/libgloss/crx/sbrk.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/sbrk.c Fri Oct 1 14:02:13 2004 *************** *** 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 + #include /* where ptrdiff_t is defined */ + #include + + /* 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; + } Index: newlib/libgloss/crx/sim.ld diff -c /dev/null newlib/libgloss/crx/sim.ld:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/sim.ld Mon Sep 27 14:45:28 2004 *************** *** 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); Index: newlib/libgloss/crx/stat.c diff -c /dev/null newlib/libgloss/crx/stat.c:1.1.2.1 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/stat.c Mon Sep 27 13:38:02 2004 *************** *** 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 + #include + + /* + * 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); + } + Index: newlib/libgloss/crx/svc_hndl.c diff -c /dev/null newlib/libgloss/crx/svc_hndl.c:1.1.2.4 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/svc_hndl.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + void svc_handler (void) __attribute__ ((interrupt ())); + + void svc_handler (void) + { + HOST_SERVICE (SVC_SVC); + } Index: newlib/libgloss/crx/time.c diff -c /dev/null newlib/libgloss/crx/time.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/time.c Fri Oct 1 14:02:13 2004 *************** *** 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 + #include + #include + #include + #include + #include + + 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; + } + Index: newlib/libgloss/crx/und_hndl.c diff -c /dev/null newlib/libgloss/crx/und_hndl.c:1.1.2.4 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/und_hndl.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + void und_handler (void) __attribute__ ((interrupt ())); + + void und_handler (void) + { + HOST_SERVICE (SVC_UND); + } Index: newlib/libgloss/crx/unlink.c diff -c /dev/null newlib/libgloss/crx/unlink.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/unlink.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + int unlink (char *path) + { + HOST_SERVICE (SVC_UNLINK); + } Index: newlib/libgloss/crx/write.c diff -c /dev/null newlib/libgloss/crx/write.c:1.1.2.2 *** /dev/null Fri Oct 1 15:00:08 2004 --- newlib/libgloss/crx/write.c Fri Oct 1 14:02:13 2004 *************** *** 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 + + int write (int fd, char *buffer, int nbytes) + { + HOST_SERVICE (SVC_WRITE); + }