diff options
author | Jeff Johnston <jjohnstn@redhat.com> | 2006-12-08 21:50:56 +0000 |
---|---|---|
committer | Jeff Johnston <jjohnstn@redhat.com> | 2006-12-08 21:50:56 +0000 |
commit | b81d0f0ec690d22faf03ed249a832ceaf1098b1c (patch) | |
tree | 26f3398952b3ce4cd62bf94e7f29cf30cb07bbad /libgloss | |
parent | da6b5ab61fcfcec3454c456cbdba939b73231665 (diff) | |
download | newlib-b81d0f0ec690d22faf03ed249a832ceaf1098b1c.zip newlib-b81d0f0ec690d22faf03ed249a832ceaf1098b1c.tar.gz newlib-b81d0f0ec690d22faf03ed249a832ceaf1098b1c.tar.bz2 |
2006-12-08 Sa Liu <saliu@de.ibm.com>
* spu/exit.c (libgloss_exit): Rename from this ..
(_exit): .. to this. Overhaul.
(exit): Remove.
* spu/crt0.S, spu/crti.S, spu/crtn.S: New files.
* spu/crt0.C, spu/init.c: Remove.
* spu/configure.in (AC_INIT): Check for crt0.S, not crt0.C.
* spu/configure: Regenerate.
* spu/Makefile.in (crti.o, crtn.o, crt1.o, crt2.o): New targets.
(OBJS): Remove init.o.
(CRTOBJS): New.
(OUTPUTS): Add $(CRTOBJS).
Diffstat (limited to 'libgloss')
-rw-r--r-- | libgloss/ChangeLog | 16 | ||||
-rw-r--r-- | libgloss/spu/Makefile.in | 18 | ||||
-rw-r--r-- | libgloss/spu/configure | 2 | ||||
-rw-r--r-- | libgloss/spu/configure.in | 2 | ||||
-rw-r--r-- | libgloss/spu/crt0.S | 168 | ||||
-rw-r--r-- | libgloss/spu/crti.S | 66 | ||||
-rw-r--r-- | libgloss/spu/crtn.S | 56 | ||||
-rw-r--r-- | libgloss/spu/exit.c | 44 | ||||
-rw-r--r-- | libgloss/spu/init.c | 37 |
9 files changed, 323 insertions, 86 deletions
diff --git a/libgloss/ChangeLog b/libgloss/ChangeLog index 2dfba15..675866b 100644 --- a/libgloss/ChangeLog +++ b/libgloss/ChangeLog @@ -1,4 +1,18 @@ -2006-11-27 Jeff Johnston <jjohnstn@redhat.com> +2006-12-08 Sa Liu <saliu@de.ibm.com> + + * spu/exit.c (libgloss_exit): Rename from this .. + (_exit): .. to this. Overhaul. + (exit): Remove. + * spu/crt0.S, spu/crti.S, spu/crtn.S: New files. + * spu/crt0.C, spu/init.c: Remove. + * spu/configure.in (AC_INIT): Check for crt0.S, not crt0.C. + * spu/configure: Regenerate. + * spu/Makefile.in (crti.o, crtn.o, crt1.o, crt2.o): New targets. + (OBJS): Remove init.o. + (CRTOBJS): New. + (OUTPUTS): Add $(CRTOBJS). + +I2006-11-27 Jeff Johnston <jjohnstn@redhat.com> * mips/crt0.S: Fix preprocessor statements from previous patch to be ANSI. diff --git a/libgloss/spu/Makefile.in b/libgloss/spu/Makefile.in index e9d79b5..b147bda 100644 --- a/libgloss/spu/Makefile.in +++ b/libgloss/spu/Makefile.in @@ -54,7 +54,7 @@ OBJDUMP = `t='$(program_transform_name)'; echo objdump | sed -e $$t` OBJCOPY = `t='$(program_transform_name)'; echo objcopy | sed -e $$t` # object files needed -OBJS = syscalls.o init.o exit.o sbrk.o close.o fstat.o getpid.o isatty.o \ +OBJS = syscalls.o exit.o sbrk.o close.o fstat.o getpid.o isatty.o \ kill.o lseek.o open.o read.o unlink.o write.o stat.o # Object files specific to particular targets. @@ -63,7 +63,8 @@ EVALOBJS = ${OBJS} GCC_LDFLAGS = `if [ -d ${objroot}/../gcc ] ; \ then echo -L${objroot}/../gcc ; fi` -OUTPUTS = libgloss.a crt0.o +CRTOBJS = crti.o crtn.o crt1.o crt2.o +OUTPUTS = libgloss.a $(CRTOBJS) NEWLIB_CFLAGS = `if [ -d ${objroot}/newlib ]; then echo -I${objroot}/newlib/targ-include -I${srcroot}/newlib/libc/include; fi` -ffunction-sections -fdata-sections NEWLIB_LDFLAGS = `if [ -d ${objroot}/newlib ]; then echo -B${objroot}/newlib/ -L${objroot}/newlib/; fi` @@ -111,6 +112,19 @@ libgloss.a: $(EVALOBJS) ${AR} ${ARFLAGS} $@ $(EVALOBJS) ${RANLIB} $@ +# C Runtime Library startup code. +crti.o: + $(CC) $(srcdir)/crti.S -c -o crti.o + +crtn.o: + $(CC) $(srcdir)/crtn.S -c -o crtn.o + +crt1.o: + $(CC) $(srcdir)/crt0.S -c -o crt1.o + +crt2.o: + $(CC) $(srcdir)/crt0.S -D_STD_MAIN -c -o crt2.o + doc: clean mostlyclean: diff --git a/libgloss/spu/configure b/libgloss/spu/configure index 9bf12dc..d339f1b 100644 --- a/libgloss/spu/configure +++ b/libgloss/spu/configure @@ -271,7 +271,7 @@ PACKAGE_VERSION= PACKAGE_STRING= PACKAGE_BUGREPORT= -ac_unique_file="crt0.c" +ac_unique_file="crt0.S" ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA CC am__leading_dot DEPDIR am__include am__quote AMDEP_TRUE AMDEP_FALSE AMDEPBACKSLASH CCDEPMODE am__fastdepCC_TRUE am__fastdepCC_FALSE AS AR LD RANLIB ac_ct_RANLIB CCAS CCASFLAGS host_makefile_frag_path LIBOBJS LTLIBOBJS' ac_subst_files='host_makefile_frag' diff --git a/libgloss/spu/configure.in b/libgloss/spu/configure.in index 992e233..3f18736 100644 --- a/libgloss/spu/configure.in +++ b/libgloss/spu/configure.in @@ -1,6 +1,6 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.59)dnl -AC_INIT(crt0.c) +AC_INIT(crt0.S) if test "$srcdir" = "." ; then if test "${with_target_subdir}" != "." ; then diff --git a/libgloss/spu/crt0.S b/libgloss/spu/crt0.S new file mode 100644 index 0000000..76d8a99 --- /dev/null +++ b/libgloss/spu/crt0.S @@ -0,0 +1,168 @@ +/* (C) Copyright IBM Corp. 2005, 2006 +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright +notice, this list of conditions and the following disclaimer in the +documentation and/or other materials provided with the distribution. + * Neither the name of IBM nor the names of its contributors may be +used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. +*/ + +/* crt0.S - entry function for C Runtime. + * + * With _STD_MAIN switch, the crt0.S will be compiled to crt2.o. + * The crt2.o sets up a C99-style interface for the SPU application's + * main() function, including a local copy of argv strings. + * + * The number of argument strings is passed in R3. The size and EA + * location of the argument vector region is passed in R4. Once the + * argv region is copied to the highest range of LS, and $SP is set + * just below it. + * + * Without _STD_MAIN, the crt0.S is compiled to crt1.o. + * The crt1.o prepares the entry for an SPU module. The main() function + * is called with different parameter list: spu_id, param and env + * are passed by R3, R4 and R5 respectively. + */ + +#ifdef _STD_MAIN +#define MFC_TAG_UPDATE_ALL 2 +#define MFC_GET_CMD 0x40 +#define TAGID 0 +#define TAGMASK 1 +#endif + +.text +.global _start +.type _start, @function + +_start: +#ifdef _STD_MAIN + /* + * Copy the argument vector region from EA to LS. The DMA + * parameters are passed in R4: + * + * +-------+-------+-------+-------+ + * R4 | LS | EA-HI | EA-LO | SIZE | + * +-------+-------+-------+-------+ + * word 0 1 2 3 + * + * By the end of this sequence, the prefered slot (word 0) of + * R4 will contain the LS offset of argv region, which also + * serves as the base offset for $SP. + */ + wrch $MFC_LSA, $4 + rotqbyi $4, $4, 4 + wrch $MFC_EAH, $4 + rotqbyi $4, $4, 4 + wrch $MFC_EAL, $4 + rotqbyi $4, $4, 4 + wrch $MFC_Size, $4 + rotqbyi $4, $4, 4 + il $LR, TAGID + wrch $MFC_TagID, $LR + + /* Issue MFC_GET_CMD, then wait for transfer of argument + * vector region to complete. + */ + il $LR, MFC_GET_CMD + wrch $MFC_Cmd, $LR + il $LR, TAGMASK + wrch $MFC_WrTagMask, $LR + il $LR, MFC_TAG_UPDATE_ALL + wrch $MFC_WrTagUpdate, $LR + rdch $LR, $MFC_RdTagStat +#endif + + /* Save parameter list of main function to the non-volatile + * registers. spu_thread module has three parameters, while + * spulet only has two. + */ + ori $80, $3, 0 + ori $81, $4, 0 +#ifndef _STD_MAIN + ori $82, $5, 0 +#endif + + /* The Link Register is initialized to NULL. + */ + il $LR, 0 + +#ifdef _STD_MAIN + /* For spulet, initialize stack pointer just below the argv region. + */ + ai $SP,$4,-16 +#else + /* For spe_thread module, the stack pointer is initialized + * below the area where __stack points to. + */ + ila $SP,__stack +#endif + /* Initialize back chain to NULL. + */ + stqd $LR,0($SP) + + /* Allocate 2 slots for stack frame. + */ + stqd $SP,-32($SP) + ai $SP,$SP,-32 + + /* Save the Link Register in Link Register Save Area. + */ + stqd $LR,16($SP) + + /* Calculate stack size. + */ + ila $3,_end + sf $3,$3,$SP + + /* The BE Linux ABI passes the stack size in $2, or use + * the default if $2 == 0. + */ + rotqbyi $4,$2,12 + ceqi $5,$4,0 + selb $3,$4,$3,$5 + fsmbi $4,3840 + selb $SP,$SP,$3,$4 + + /* Call the _init function. + */ + brsl $LR, _init + + /* Call the _fini function at exit time. + */ + ila $3, _fini + brsl $LR, atexit + + ori $3,$80,0 + ori $4,$81,0 +#ifndef _STD_MAIN + ori $5,$82,0 +#endif + + /* Call the programs main. + */ + brsl $LR, main + + /* Call exit. + */ + brsl $LR, exit + diff --git a/libgloss/spu/crti.S b/libgloss/spu/crti.S new file mode 100644 index 0000000..8e7f55d --- /dev/null +++ b/libgloss/spu/crti.S @@ -0,0 +1,66 @@ +# (C) Copyright IBM Corp. 2005, 2006 +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of IBM nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This file just make a stack frame for the contents of the .fini and +# .init sections. Users may put any desired instructions in those +# sections. + + # Note - this macro is complimented by the FUNC_END macro + # in crtn.S. If you change this macro you must also change + # that macro match. +.macro FUNC_START + # Create a stack frame with two slots: LR and BC + # The .init and .fini section don't change the call-preserved + # registes, therefore no need to save them. + stqd $lr, 16($sp) + stqd $sp, -32($sp) + ai $sp, $sp, -32 +.endm + + .file "crti.S" + + .section ".init" + .align 2 + + # To make sure the address of _init is not zero, because + # the default linker entry point is 0. + nop + + .global _init + .type _init, @function +_init: + FUNC_START + + + .section ".fini" + .align 2 + .global _fini + .type _fini, @function +_fini: + FUNC_START + diff --git a/libgloss/spu/crtn.S b/libgloss/spu/crtn.S new file mode 100644 index 0000000..8812f1f --- /dev/null +++ b/libgloss/spu/crtn.S @@ -0,0 +1,56 @@ +# (C) Copyright IBM Corp. 2005, 2006 +# +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# * Neither the name of IBM nor the names of its contributors may be +# used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +# This file just makes sure that the .fini and .init sections do in +# fact return. Users may put any desired instructions in those sections. +# This file is the last thing linked into any executable. + + # Note - this macro is complimented by the FUNC_START macro + # in crti.S. If you change this macro you must also change + # that macro match. + # + # Note - we do not try any fancy optimisations of the return + # sequences here, it is just not worth it. Instead keep things + # simple. The link register is restored and then the correct + # function return instruction is performed. +.macro FUNC_END + ai $sp, $sp, 32 + lqd $lr, 16($sp) + bi $lr +.endm + .file "crtn.S" + + .section ".init" + + FUNC_END + + .section ".fini" + + FUNC_END + +# end of crtn.S diff --git a/libgloss/spu/exit.c b/libgloss/spu/exit.c deleted file mode 100644 index 6693388..0000000 --- a/libgloss/spu/exit.c +++ /dev/null @@ -1,44 +0,0 @@ -/* -(C) Copyright IBM Corp. 2005, 2006 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - * Neither the name of IBM nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -Author: Andreas Neukoetter (ti95neuk@de.ibm.com) -*/ - -void __attribute__ (( destructor )) libgloss_exit( void ) -{ - /* we don't need any cleanup on the SPE ... yet */ - /* DEBUG HERE */ -} - -void exit( int status ) -{ - /* handle atexit, etc here */ - _exit( status ); -} - diff --git a/libgloss/spu/init.c b/libgloss/spu/init.c deleted file mode 100644 index 66d6a25..0000000 --- a/libgloss/spu/init.c +++ /dev/null @@ -1,37 +0,0 @@ -/* -(C) Copyright IBM Corp. 2005, 2006 - -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, -this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above copyright -notice, this list of conditions and the following disclaimer in the -documentation and/or other materials provided with the distribution. - * Neither the name of IBM nor the names of its contributors may be -used to endorse or promote products derived from this software without -specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. - -Author: Andreas Neukoetter (ti95neuk@de.ibm.com) -*/ - -void __attribute__ (( constructor )) libgloss_init( void ) -{ - -} - |