[PATCH] Add Blackfin support in newlib (try 3) (was Re: [PATCH] Add Blackfin support in newlib (try 2))
Joel Sherrill
joel.sherrill@oarcorp.com
Thu Oct 26 18:44:00 GMT 2006
Jie Zhang wrote:
> Hi all,
>
> Here is a third patch for adding Blackfin support in newlib. I should
> send it out sooner. But I was waiting for Bernd's opinion without
> knowing he's on vocation.
>
> This patch has fixed these more issues:
>
It looks like it is getting there. The license is OK for newlib now and
you have setjmp/longjmp.
AFAIK machine/bfin should not have access.c or sys/syscall.h. Those are
part of the target OS
which in your case is libgloss. For RTEMS, we could use setjmp/longjmp
but would
avoid those since we really have a functional access and those syscall's
are meaningless.
--joel
> Michael Ambrus wrote:
>>> > Jeff Johnston wrote:
>>> >> I forgot another issue. The bfin processor should be using
>>> >> underscored cpu macros from the compiler. That is, you should be
>>> >> looking for __BFIN__ or __bfin__ inside newlib header files: not
>>> "BFIN"
>>> >> or "bfin". The latter two are in the user's namespace.
>>> >
>>> > Michael Ambrus wrote:
>>> >>
>>> >> - The usage of the predefined BFIN macro in machine/ieeefp.h will
>>> lead
>>> >> to the same compiling issues as mentioned in:
>>> >> http://sourceware.org/ml/newlib/2006/msg00787.html
>>> >> http://sourceware.org/ml/newlib/2006/msg00791.html
>>> >
>>> > As for these two macros, they were in our CVS(*) long long ago. I
>>> admit
>>> > they look weird and uncommon. But considering they have been used in
>>> > many code in such long time, we have to estimate its impact before
>>> doing
>>> > any change.
>>
> In private emails, Michael helped me to reproduce it on my machine. So
> I can take a close look at it. The fix is to use builtin_define_std
> instead of builtin_define for bfin and BFIN. The patch:
>
> <http://gcc.gnu.org/ml/gcc-patches/2006-10/msg01349.html>
>
> It's still waiting for Bernd's OK to go into GCC SVN. (He's on a two
> weeks vocation now.)
>
>>> > Michael Ambrus wrote:
>>> >>
>>> >> - Both setjmp and longjmp are lacking (or according to the
>>> current gcc
>>> >> release, it's rather _setjmp and _longjmp). If your application or
>>> >> Newlib (or other libraries) don't need them, the build will pass
>>> >> however.
>>> >>
>>> >> - The implementation of ___sigsetjmp is not needed. If I'm not
>>> >> mistaken, sigsetjmp and siglongjmp are wrapped around setjmp and
>>> >> longjmp macros in machine/setjmp.h.
>>> >
> Done! _setjmp and _longjmp have been defined. ___sigsetjmp has been
> removed.
>
>
> So the the only one comment I have not done is
>
> Jeff Johnston wrote:
> > For your libc/machine/bfin Makefile.am, please look at the
> > libc/machine/fr30 directory. You should base your Makefile.am on that
> > (adding any other files to lib_a_SOURCES). This sets some flags needed
> > to ensure compilation flags are passed properly down from the
> top-level.
>
> Jeff,
>
> Do you means define AM_CCASFLAGS, lib_a_CCASFLAGS and lib_a_CFLAGS as
> in fr30?
>
> I found I need automake 1.9.5 to generate Makefile.in. Is it in plan
> to update newlib to use automake 1.9.6?
>
>
> Thanks,
> Jie
> ------------------------------------------------------------------------
>
>
> toplevel/
> * configure.in: Remove target-libgloss from noconfigdirs for
> bfin-*-*.
>
> libgloss/
> * bfin/aclocal.m4: Generate.
> * bfin/configure.in: New.
> * bfin/configure: Generate.
> * bfin/crt0.S: New.
> * bfin/Makefile.in: New.
> * bfin/syscalls.c: New.
> * configure.in: Add support for bfin-*-*.
> * configure: Regenerate.
>
> newlib/
> * configure.host: Add support for bfin.
> * libc/include/machine/ieeefp.h: Define __IEEE_LITTLE_ENDIAN for bfin.
> * libc/include/machine/setjmp.h: Define _JBLEN for bfin.
> * libc/machine/bfin/access.c: New.
> * libc/machine/bfin/aclocal.m4: Generate.
> * libc/machine/bfin/configure.in: New.
> * libc/machine/bfin/configure: Generate.
> * libc/machine/bfin/Makefile.am: New.
> * libc/machine/bfin/Makefile.in: Generate.
> * libc/machine/bfin/setjmp.S: New.
> * libc/machine/bfin/longjmp.S: New.
> * libc/machine/bfin/sys/syscall.h: New.
> * libc/machine/configure.in: Add bfin support.
> * libc/machine/configure: Generate.
>
> diff -r -u -p -N -x CVS newlib-orig/src/configure.in newlib/src/configure.in
> --- newlib-orig/src/configure.in 2006-10-11 00:50:34.000000000 +0800
> +++ newlib/src/configure.in 2006-10-21 02:43:05.000000000 +0800
> @@ -507,7 +507,7 @@ case "${target}" in
> noconfigdirs="$noconfigdirs target-libiberty target-libstdc++-v3 ${libgcj}"
> ;;
> bfin-*-*)
> - noconfigdirs="$noconfigdirs target-libgloss gdb"
> + noconfigdirs="$noconfigdirs gdb"
> if test x${is_cross_compiler} != xno ; then
> target_configdirs="${target_configdirs} target-bsp target-cygmon"
> fi
> diff -r -u -p -N -x CVS newlib-orig/src/libgloss/bfin/configure.in newlib/src/libgloss/bfin/configure.in
> --- newlib-orig/src/libgloss/bfin/configure.in 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/libgloss/bfin/configure.in 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,54 @@
> +dnl Process this file with autoconf to produce a configure script.
> +AC_PREREQ(2.59)
> +AC_INIT(crt0.S)
> +
> +if test "${enable_shared}" = "yes" ; then
> + echo "Shared libraries not supported for cross compiling, ignored"
> +fi
> +
> +if test "$srcdir" = "." ; then
> + if test "${with_target_subdir}" != "." ; then
> + libgloss_topdir="${srcdir}/${with_multisrctop}../../.."
> + else
> + libgloss_topdir="${srcdir}/${with_multisrctop}../.."
> + fi
> +else
> + libgloss_topdir="${srcdir}/../.."
> +fi
> +AC_CONFIG_AUX_DIR($libgloss_topdir)
> +
> +AC_CANONICAL_SYSTEM
> +AC_ARG_PROGRAM
> +
> +AC_PROG_INSTALL
> +
> +LIB_AC_PROG_CC
> +AS=${AS-as}
> +AC_SUBST(AS)
> +AR=${AR-ar}
> +AC_SUBST(AR)
> +LD=${LD-ld}
> +AC_SUBST(LD)
> +AC_PROG_RANLIB
> +LIB_AM_PROG_AS
> +
> +host_makefile_frag=${srcdir}/../config/default.mh
> +
> +dnl We have to assign the same value to other variables because autoconf
> +dnl doesn't provide a mechanism to substitute a replacement keyword with
> +dnl arbitrary data or pathnames.
> +dnl
> +host_makefile_frag_path=$host_makefile_frag
> +AC_SUBST(host_makefile_frag_path)
> +AC_SUBST_FILE(host_makefile_frag)
> +
> +AC_CONFIG_FILES(Makefile,
> +. ${libgloss_topdir}/config-ml.in,
> +srcdir=${srcdir}
> +target=${target}
> +with_multisubdir=${with_multisubdir}
> +ac_configure_args="${ac_configure_args} --enable-multilib"
> +CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
> +libgloss_topdir=${libgloss_topdir}
> +)
> +AC_OUTPUT
> diff -r -u -p -N -x CVS newlib-orig/src/libgloss/bfin/crt0.S newlib/src/libgloss/bfin/crt0.S
> --- newlib-orig/src/libgloss/bfin/crt0.S 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/libgloss/bfin/crt0.S 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,72 @@
> +/*
> + * crt0.S for the Blackfin processor
> + *
> + * Copyright (C) 2006 Analog Devices, 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.
> + */
> +
> + .text
> + .align 2
> +
> + .global __start
> +__start:
> +
> + /* Start by setting up a stack */
> + link 0xc;
> + /* Zero the memory in the .bss section. */
> +
> + p0.l = __edata;
> + p0.h = __edata;
> + p1.l = __end;
> + p1.h = __end;
> + p1 -= p0;
> + r0 = 0;
> + lsetup (L$L$clear_bss, L$L$clear_bss) lc0 = p1;
> +L$L$clear_bss:
> + B [p0++] = r0;
> +
> +#ifdef __BFIN_FDPIC__
> + /* Set up GOT pointer. */
> + P0.L = __ROFIXUP_END__;
> + P0.H = __ROFIXUP_END__;
> + P4 = [P0 - 4];
> +#endif
> +
> + /* Need to set up standard file handles */
> + /* Parse string at r1 */
> +
> + p0.l = __init;
> + p0.h = __init;
> + P3 = P4;
> + call (p0)
> +
> + p0.l = _atexit;
> + p0.h = _atexit;
> +#ifdef __BFIN_FDPIC__
> + r0 = [P4 + __fini@FUNCDESC_GOT17M4] ;
> + P3 = P4;
> +#else
> + r0.l = __fini;
> + r0.h = __fini;
> +#endif
> + call (p0)
> +
> + p0.l = ___setup_argv_and_call_main;
> + p0.h = ___setup_argv_and_call_main;
> + P3 = P4;
> + call (p0)
> +
> + p0.l = _exit;
> + p0.h = _exit;
> + P3 = P4;
> + jump (p0) /* Should not return. */
> + nop;
> diff -r -u -p -N -x CVS newlib-orig/src/libgloss/bfin/Makefile.in newlib/src/libgloss/bfin/Makefile.in
> --- newlib-orig/src/libgloss/bfin/Makefile.in 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/libgloss/bfin/Makefile.in 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,102 @@
> +#
> +#
> +
> +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`
> +
> +OBJS =
> +CFLAGS =
> +SCRIPTS =
> +
> +# Here is all of the simulator stuff
> +SIM_SCRIPTS =
> +SIM_LDFLAGS =
> +SIM_BSP = libsim.a
> +SIM_CRT0 = crt0.o
> +SIM_OBJS = syscalls.o
> +SIM_TEST = sim-test
> +SIM_INSTALL = install-sim
> +
> +# 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: ${SIM_CRT0} ${SIM_BSP}
> +
> +#
> +# here's where we build the board support packages for each target
> +#
> +${SIM_BSP}: ${OBJS} ${SIM_OBJS}
> + ${AR} ${ARFLAGS} ${SIM_BSP} ${SIM_OBJS} ${OBJS}
> + ${RANLIB} ${SIM_BSP}
> +
> +#
> +#
> +#
> +.c.S:
> + ${CC} ${CFLAGS_FOR_TARGET} -c $<
> +
> +clean mostlyclean:
> + rm -f a.out core *.i *.o $(SIM_BSP)
> +
> +distclean maintainer-clean realclean: clean
> + rm -f Makefile config.status *~
> +
> +.PHONY: install info install-info clean-info
> +install: ${SIM_INSTALL}
> +
> +install-sim:
> + set -e; for x in ${SIM_CRT0} ${SIM_BSP} ${SIM_SCRIPTS}; do ${INSTALL_DATA} $$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
> diff -r -u -p -N -x CVS newlib-orig/src/libgloss/bfin/syscalls.c newlib/src/libgloss/bfin/syscalls.c
> --- newlib-orig/src/libgloss/bfin/syscalls.c 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/libgloss/bfin/syscalls.c 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,264 @@
> +/*
> + * C library support files for the Blackfin processor
> + *
> + * Copyright (C) 2006 Analog Devices, 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 <_ansi.h>
> +#include <sys/types.h>
> +#include <sys/stat.h>
> +#include <sys/fcntl.h>
> +#include <stdio.h>
> +#include <time.h>
> +#include <sys/time.h>
> +#include <sys/times.h>
> +#include "sys/syscall.h"
> +#include <errno.h>
> +#include <reent.h>
> +#include <unistd.h>
> +
> +register char *stack_ptr asm ("SP");
> +
> +static inline int
> +do_syscall (int reason, void *arg)
> +{
> + int result;
> + asm volatile ("[--sp] = %1; [--sp] = %2; \
> + r1 = [sp++]; r0 = [sp++]; \
> + raise 0; %0 = r0;"
> + : "=r" (result)
> + : "r" (reason), "r" (arg)
> + : "R0", "R1", "memory", "cc");
> + return result;
> +}
> +
> +int
> +_read (int file, char *ptr, int len)
> +{
> + int block[3];
> +
> + block[0] = file;
> + block[1] = (int) ptr;
> + block[2] = len;
> +
> + return do_syscall (SYS_read, block);
> +}
> +
> +int
> +_lseek (int file, int ptr, int dir)
> +{
> + int block[2];
> +
> + block[0] = file;
> + block[1] = ptr;
> +
> + return do_syscall (SYS_lseek, block);
> +}
> +
> +int
> +_write (int file, char *ptr, int len)
> +{
> + int block[3];
> +
> + block[0] = file;
> + block[1] = (int) ptr;
> + block[2] = len;
> +
> + return do_syscall (SYS_write, block);
> +}
> +
> +int
> +_open (const char *path, int flags)
> +{
> + int block[2];
> +
> + block[0] = (int) path;
> + block[1] = flags;
> +
> + return do_syscall (SYS_open, block);
> +}
> +
> +int
> +_close (int file)
> +{
> + return do_syscall (SYS_close, &file);
> +}
> +
> +void
> +_exit (int n)
> +{
> + do_syscall (SYS_exit, &n);
> +}
> +
> +int
> +_kill (int n, int m)
> +{
> + int block[2];
> +
> + block[0] = n;
> + block[1] = m;
> +
> + return do_syscall (SYS_kill, block);
> +}
> +
> +int
> +_getpid (int n)
> +{
> + return 1;
> +}
> +
> +caddr_t
> +_sbrk (int incr)
> +{
> + extern char end; /* Defined by the linker. */
> + static char *heap_end;
> + char *prev_heap_end;
> +
> + if (heap_end == NULL)
> + heap_end = &end;
> +
> + prev_heap_end = heap_end;
> +
> + if (heap_end + incr > stack_ptr)
> + {
> + /* Some of the libstdc++-v3 tests rely upon detecting
> + out of memory errors, so do not abort here. */
> +#if 0
> + extern void abort (void);
> +
> + _write (1, "_sbrk: Heap and stack collision\n", 32);
> +
> + abort ();
> +#else
> + errno = ENOMEM;
> + return (caddr_t) -1;
> +#endif
> + }
> +
> + heap_end += incr;
> +
> + return (caddr_t) prev_heap_end;
> +}
> +
> +extern void memset (struct stat *, int, unsigned int);
> +
> +int
> +_fstat (int file, struct stat * st)
> +{
> + memset (st, 0, sizeof (* st));
> + st->st_mode = S_IFCHR;
> + st->st_blksize = 1024;
> + return 0;
> +}
> +
> +int _stat (const char *fname, struct stat *st)
> +{
> + int file;
> +
> + /* The best we can do is try to open the file readonly. If it exists,
> + then we can guess a few things about it. */
> + if ((file = _open (fname, O_RDONLY)) < 0)
> + return -1;
> +
> + memset (st, 0, sizeof (* st));
> + st->st_mode = S_IFREG | S_IREAD;
> + st->st_blksize = 1024;
> + _close (file); /* Not interested in the error. */
> + return 0;
> +}
> +
> +int
> +_link (void)
> +{
> + return -1;
> +}
> +
> +int
> +_unlink (void)
> +{
> + return -1;
> +}
> +
> +void
> +_raise (void)
> +{
> + return;
> +}
> +
> +int
> +_gettimeofday (struct timeval *tv, struct timezone *tz)
> +{
> + tv->tv_usec = 0;
> + tv->tv_sec = do_syscall (SYS_time, 0);
> + return 0;
> +}
> +
> +/* Return a clock that ticks at 100Hz. */
> +clock_t
> +_times (struct tms * tp)
> +{
> + return -1;
> +}
> +
> +int
> +isatty (int fd)
> +{
> + return 1;
> +}
> +
> +int
> +_system (const char *s)
> +{
> + if (s == NULL)
> + return 0;
> + errno = ENOSYS;
> + return -1;
> +}
> +
> +int
> +_rename (const char * oldpath, const char * newpath)
> +{
> + errno = ENOSYS;
> + return -1;
> +}
> +
> +static inline int
> +__setup_argv_for_main (int argc)
> +{
> + int block[2];
> + char **argv;
> + int i = argc;
> +
> + argv = __builtin_alloca ((1 + argc) * sizeof (*argv));
> +
> + argv[i] = NULL;
> + while (i--) {
> + block[0] = i;
> + argv[i] = __builtin_alloca (1 + do_syscall (SYS_argnlen, (void *)block));
> + block[1] = (int) argv[i];
> + do_syscall (SYS_argn, (void *)block);
> + }
> +
> + return main (argc, argv);
> +}
> +
> +int
> +__setup_argv_and_call_main ()
> +{
> + int argc = do_syscall (SYS_argc, 0);
> +
> + if (argc <= 0)
> + return main (argc, NULL);
> + else
> + return __setup_argv_for_main (argc);
> +}
> diff -r -u -p -N -x CVS newlib-orig/src/libgloss/configure.in newlib/src/libgloss/configure.in
> --- newlib-orig/src/libgloss/configure.in 2006-10-11 00:50:02.000000000 +0800
> +++ newlib/src/libgloss/configure.in 2006-10-21 02:43:05.000000000 +0800
> @@ -77,6 +77,10 @@ case "${target}" in
> AC_CONFIG_SUBDIRS(mn10300)
> config_testsuite = true;
> ;;
> + bfin-*-*)
> + AC_CONFIG_SUBDIRS(bfin)
> + config_testsuite = true;
> + ;;
> cris-*-* | crisv32-*-*)
> AC_CONFIG_SUBDIRS(cris)
> config_testsuite = true;
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/configure.host newlib/src/newlib/configure.host
> --- newlib-orig/src/newlib/configure.host 2006-10-11 00:50:06.000000000 +0800
> +++ newlib/src/newlib/configure.host 2006-10-21 02:43:05.000000000 +0800
> @@ -99,6 +99,9 @@ case "${host_cpu}" in
> avr*)
> newlib_cflags="${newlib_cflags} -DPREFER_SIZE_OVER_SPEED -mcall-prologues"
> ;;
> + bfin)
> + machine_dir=bfin
> + ;;
> cris | crisv32)
> machine_dir=cris
> ;;
> @@ -334,6 +337,9 @@ case "${host}" in
> have_crt0="no"
> fi
> ;;
> + bfin-*-*)
> + sys_dir=
> + ;;
> crx*)
> sys_dir=
> ;;
> @@ -539,6 +545,9 @@ case "${host}" in
> avr*)
> newlib_cflags="${newlib_cflags} -DNO_EXEC -DSMALL_MEMORY -DMISSING_SYSCALL_NAMES"
> ;;
> + bfin*)
> + syscall_dir=syscalls
> + ;;
> cris-*-* | crisv32-*-*)
> default_newlib_io_long_long="yes"
> newlib_cflags="${newlib_cflags} -DHAVE_RENAME -D_USE_WRITE -DCOMPACT_CTYPE"
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/include/machine/ieeefp.h newlib/src/newlib/libc/include/machine/ieeefp.h
> --- newlib-orig/src/newlib/libc/include/machine/ieeefp.h 2006-10-11 00:50:07.000000000 +0800
> +++ newlib/src/newlib/libc/include/machine/ieeefp.h 2006-10-26 17:43:13.000000000 +0800
> @@ -283,6 +283,10 @@
> #define __IEEE_LITTLE_ENDIAN
> #endif
>
> +#ifdef __BFIN__
> +#define __IEEE_LITTLE_ENDIAN
> +#endif
> +
> #ifndef __IEEE_BIG_ENDIAN
> #ifndef __IEEE_LITTLE_ENDIAN
> #error Endianess not declared!!
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/include/machine/setjmp.h newlib/src/newlib/libc/include/machine/setjmp.h
> --- newlib-orig/src/newlib/libc/include/machine/setjmp.h 2006-10-11 00:50:07.000000000 +0800
> +++ newlib/src/newlib/libc/include/machine/setjmp.h 2006-10-26 17:43:33.000000000 +0800
> @@ -21,6 +21,10 @@ _BEGIN_STD_C
> #define _JBLEN 13
> #endif
>
> +#ifdef __BFIN__
> +#define _JBLEN 40
> +#endif
> +
> /* necv70 was 9 as well. */
>
> #ifdef __mc68000__
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/bfin/access.c newlib/src/newlib/libc/machine/bfin/access.c
> --- newlib-orig/src/newlib/libc/machine/bfin/access.c 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/newlib/libc/machine/bfin/access.c 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,33 @@
> +/* This is file ACCESS.C */
> +/*
> + * Copyright (C) 1993 DJ Delorie
> + * All rights reserved.
> + *
> + * Redistribution and use in source and binary forms is permitted
> + * provided that the above copyright notice and following paragraph are
> + * duplicated in all such forms.
> + *
> + * This file is distributed WITHOUT ANY WARRANTY; without even the implied
> + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
> + */
> +
> +#include <fcntl.h>
> +#include <sys/stat.h>
> +#include <unistd.h>
> +
> +int access(const char *fn, int flags)
> +{
> + struct stat s;
> + if (stat(fn, &s))
> + return -1;
> + if (s.st_mode & S_IFDIR)
> + return 0;
> + if (flags & W_OK)
> + {
> + if (s.st_mode & S_IWRITE)
> + return 0;
> + return -1;
> + }
> + return 0;
> +}
> +
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/bfin/configure.in newlib/src/newlib/libc/machine/bfin/configure.in
> --- newlib-orig/src/newlib/libc/machine/bfin/configure.in 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/newlib/libc/machine/bfin/configure.in 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,14 @@
> +dnl This is the newlib/libc/machine/bfin configure.in file.
> +dnl Process this file with autoconf to produce a configure script.
> +
> +AC_PREREQ(2.59)
> +AC_INIT([newlib],[NEWLIB_VERSION])
> +AC_CONFIG_SRCDIR([Makefile.am])
> +
> +dnl Can't be done in NEWLIB_CONFIGURE because that confuses automake.
> +AC_CONFIG_AUX_DIR(../../../..)
> +
> +NEWLIB_CONFIGURE(../../..)
> +
> +AC_CONFIG_FILES([Makefile])
> +AC_OUTPUT
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/bfin/longjmp.S newlib/src/newlib/libc/machine/bfin/longjmp.S
> --- newlib-orig/src/newlib/libc/machine/bfin/longjmp.S 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/newlib/libc/machine/bfin/longjmp.S 2006-10-23 15:33:26.000000000 +0800
> @@ -0,0 +1,115 @@
> +/*
> + * longjmp for the Blackfin processor
> + *
> + * Copyright (C) 2006 Analog Devices, 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.
> + */
> +
> +#define _ASM
> +#define _SETJMP_H
> +
> +
> +.text;
> +.align 4;
> +.globl _longjmp;
> +.type _longjmp, STT_FUNC;
> +_longjmp:
> + P0 = R0;
> + R0 = [P0 + 0x00];
> + [--SP] = R0; /* Put P0 on the stack */
> +
> + P1 = [P0 + 0x04];
> + P2 = [P0 + 0x08];
> + P3 = [P0 + 0x0C];
> + P4 = [P0 + 0x10];
> + P5 = [P0 + 0x14];
> +
> + FP = [P0 + 0x18];
> + R0 = [SP++]; /* Grab P0 from old stack */
> + SP = [P0 + 0x1C]; /* Update Stack Pointer */
> + [--SP] = R0; /* Put P0 on new stack */
> + [--SP] = R1; /* Put VAL arg on new stack */
> +
> + R0 = [P0 + 0x20]; /* Data Registers */
> + R1 = [P0 + 0x24];
> + R2 = [P0 + 0x28];
> + R3 = [P0 + 0x2C];
> + R4 = [P0 + 0x30];
> + R5 = [P0 + 0x34];
> + R6 = [P0 + 0x38];
> + R7 = [P0 + 0x3C];
> +
> + R0 = [P0 + 0x40];
> + ASTAT = R0;
> +
> + R0 = [P0 + 0x44]; /* Loop Counters */
> + LC0 = R0;
> + R0 = [P0 + 0x48];
> + LC1 = R0;
> +
> + R0 = [P0 + 0x4C]; /* Accumulators */
> + A0.W = R0;
> + R0 = [P0 + 0x50];
> + A0.X = R0;
> + R0 = [P0 + 0x54];
> + A1.W = R0;
> + R0 = [P0 + 0x58];
> + A1.X = R0;
> +
> + R0 = [P0 + 0x5C]; /* Index Registers */
> + I0 = R0;
> + R0 = [P0 + 0x60];
> + I1 = R0;
> + R0 = [P0 + 0x64];
> + I2 = R0;
> + R0 = [P0 + 0x68];
> + I3 = R0;
> +
> + R0 = [P0 + 0x6C]; /* Modifier Registers */
> + M0 = R0;
> + R0 = [P0 + 0x70];
> + M1 = R0;
> + R0 = [P0 + 0x74];
> + M2 = R0;
> + R0 = [P0 + 0x78];
> + M3 = R0;
> +
> + R0 = [P0 + 0x7C]; /* Length Registers */
> + L0 = R0;
> + R0 = [P0 + 0x80];
> + L1 = R0;
> + R0 = [P0 + 0x84];
> + L2 = R0;
> + R0 = [P0 + 0x88];
> + L3 = R0;
> +
> + R0 = [P0 + 0x8C]; /* Base Registers */
> + B0 = R0;
> + R0 = [P0 + 0x90];
> + B1 = R0;
> + R0 = [P0 + 0x94];
> + B2 = R0;
> + R0 = [P0 + 0x98];
> + B3 = R0;
> +
> + R0 = [P0 + 0x9C]; /* Return Address (PC) */
> + RETS = R0;
> +
> + R0 = [SP++];
> + P0 = [SP++];
> +
> + CC = R0 == 0;
> + IF !CC JUMP 1f;
> + R0 = 1;
> +1:
> + RTS;
> +.size _longjmp, .-_longjmp;
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/bfin/Makefile.am newlib/src/newlib/libc/machine/bfin/Makefile.am
> --- newlib-orig/src/newlib/libc/machine/bfin/Makefile.am 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/newlib/libc/machine/bfin/Makefile.am 2006-10-23 15:33:43.000000000 +0800
> @@ -0,0 +1,12 @@
> +## Process this file with automake to generate Makefile.in
> +
> +AUTOMAKE_OPTIONS = cygnus
> +
> +INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
> +
> +noinst_LIBRARIES = lib.a
> +
> +lib_a_SOURCES = setjmp.S longjmp.S access.c
> +
> +ACLOCAL_AMFLAGS = -I ../../..
> +CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/bfin/setjmp.S newlib/src/newlib/libc/machine/bfin/setjmp.S
> --- newlib-orig/src/newlib/libc/machine/bfin/setjmp.S 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/newlib/libc/machine/bfin/setjmp.S 2006-10-23 15:31:57.000000000 +0800
> @@ -0,0 +1,108 @@
> +/*
> + * setjmp for the Blackfin processor
> + *
> + * Copyright (C) 2006 Analog Devices, 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.
> + */
> +
> +
> +#define _ASM
> +#define _SETJMP_H
> +
> +.text;
> +.align 4;
> +.globl _setjmp;
> +.type _setjmp, STT_FUNC;
> +
> +_setjmp:
> + [--SP] = P0; /* Save P0 */
> + P0 = R0;
> + R0 = [SP++];
> + [P0 + 0x00] = R0; /* Save saved P0 */
> + [P0 + 0x04] = P1;
> + [P0 + 0x08] = P2;
> + [P0 + 0x0C] = P3;
> + [P0 + 0x10] = P4;
> + [P0 + 0x14] = P5;
> +
> + [P0 + 0x18] = FP; /* Frame Pointer */
> + [P0 + 0x1C] = SP; /* Stack Pointer */
> +
> + [P0 + 0x20] = P0; /* Data Registers */
> + [P0 + 0x24] = R1;
> + [P0 + 0x28] = R2;
> + [P0 + 0x2C] = R3;
> + [P0 + 0x30] = R4;
> + [P0 + 0x34] = R5;
> + [P0 + 0x38] = R6;
> + [P0 + 0x3C] = R7;
> +
> + R0 = ASTAT;
> + [P0 + 0x40] = R0;
> +
> + R0 = LC0; /* Loop Counters */
> + [P0 + 0x44] = R0;
> + R0 = LC1;
> + [P0 + 0x48] = R0;
> +
> + R0 = A0.W; /* Accumulators */
> + [P0 + 0x4C] = R0;
> + R0 = A0.X;
> + [P0 + 0x50] = R0;
> + R0 = A1.W;
> + [P0 + 0x54] = R0;
> + R0 = A1.X;
> + [P0 + 0x58] = R0;
> +
> + R0 = I0; /* Index Registers */
> + [P0 + 0x5C] = R0;
> + R0 = I1;
> + [P0 + 0x60] = R0;
> + R0 = I2;
> + [P0 + 0x64] = R0;
> + R0 = I3;
> + [P0 + 0x68] = R0;
> +
> + R0 = M0; /* Modifier Registers */
> + [P0 + 0x6C] = R0;
> + R0 = M1;
> + [P0 + 0x70] = R0;
> + R0 = M2;
> + [P0 + 0x74] = R0;
> + R0 = M3;
> + [P0 + 0x78] = R0;
> +
> + R0 = L0; /* Length Registers */
> + [P0 + 0x7c] = R0;
> + R0 = L1;
> + [P0 + 0x80] = R0;
> + R0 = L2;
> + [P0 + 0x84] = R0;
> + R0 = L3;
> + [P0 + 0x88] = R0;
> +
> + R0 = B0; /* Base Registers */
> + [P0 + 0x8C] = R0;
> + R0 = B1;
> + [P0 + 0x90] = R0;
> + R0 = B2;
> + [P0 + 0x94] = R0;
> + R0 = B3;
> + [P0 + 0x98] = R0;
> +
> + R0 = RETS;
> + [P0 + 0x9C] = R0;
> +
> + R0 = 0;
> +
> + RTS;
> +.size _setjmp, .-_setjmp;
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/bfin/sys/syscall.h newlib/src/newlib/libc/machine/bfin/sys/syscall.h
> --- newlib-orig/src/newlib/libc/machine/bfin/sys/syscall.h 1970-01-01 08:00:00.000000000 +0800
> +++ newlib/src/newlib/libc/machine/bfin/sys/syscall.h 2006-10-21 02:43:05.000000000 +0800
> @@ -0,0 +1,56 @@
> +/*
> + * System call number for the Blackfin processor
> + *
> + * Copyright (C) 2006 Analog Devices, 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.
> + */
> +
> +
> +#define SYS_exit 1
> +#define SYS_fork 2
> +#define SYS_read 3
> +#define SYS_write 4
> +#define SYS_open 5
> +#define SYS_close 6
> +#define SYS_wait4 7
> +#define SYS_creat 8
> +#define SYS_link 9
> +#define SYS_unlink 10
> +#define SYS_execv 11
> +#define SYS_chdir 12
> +
> +#define SYS_mknod 14
> +#define SYS_chmod 15
> +#define SYS_chown 16
> +
> +#define SYS_lseek 19
> +#define SYS_getpid 20
> +#define SYS_isatty 21
> +#define SYS_fstat 22
> +#define SYS_time 23
> +#define SYS_kill 24
> +
> +#define SYS_stat 38
> +
> +#define SYS_pipe 42
> +
> +#define SYS_execve 59
> +
> +#define SYS_truncate 129
> +#define SYS_ftruncate 130
> +
> +#define SYS_argc 172
> +#define SYS_argnlen 173
> +#define SYS_argn 174
> +
> +#define SYS_utime 201
> +#define SYS_wait 202
> diff -r -u -p -N -x CVS newlib-orig/src/newlib/libc/machine/configure.in newlib/src/newlib/libc/machine/configure.in
> --- newlib-orig/src/newlib/libc/machine/configure.in 2006-10-11 00:50:07.000000000 +0800
> +++ newlib/src/newlib/libc/machine/configure.in 2006-10-21 02:43:05.000000000 +0800
> @@ -24,6 +24,7 @@ if test -n "${machine_dir}"; then
> case ${machine_dir} in
> a29k) AC_CONFIG_SUBDIRS(a29k) ;;
> arm) AC_CONFIG_SUBDIRS(arm) ;;
> + bfin) AC_CONFIG_SUBDIRS(bfin) ;;
> cris) AC_CONFIG_SUBDIRS(cris) ;;
> crx) AC_CONFIG_SUBDIRS(crx) ;;
> d10v) AC_CONFIG_SUBDIRS(d10v) ;;
>
More information about the Newlib
mailing list