summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/c6x/clone.S
diff options
context:
space:
mode:
authorCarmelo Amoroso <carmelo.amoroso@st.com>2011-04-06 15:13:59 +0200
committerCarmelo Amoroso <carmelo.amoroso@st.com>2011-04-06 15:13:59 +0200
commit3b3285b1b7c02d36c74a6ae265fdb02ca991c96b (patch)
tree0f3bf060794323ff690f6f4a86dc903c4570f540 /libc/sysdeps/linux/c6x/clone.S
parent289d19f45d7f8af9a4079938a3426aafdd2674ba (diff)
parent85f4b028d767fc390a7b866d2f58d58be489242d (diff)
Merge remote-tracking branch 'origin/master' into prelink
* origin/master: (137 commits) utils/ldd: Check for returned pointer from strrchr not the value it holds cris: add provide arch-specific vfork implementation lutimes.c, stubs.c: fix compiling lutimes, if __NR_utimensat is not defined bump version to 0.9.32-rc3-git release 0.9.32-rc3 memalign: include sys/param.h for MAX arm/bits/atomic.h: Include common/bit/atomic.h for thumb1 wctype.h: fix libc_hidden_proto for iswupper and add it for iswspace add libc_hidden_proto for wcs[n]casecmp_l really fix missing __libc_drand48_data Revert "missing prototype of __libc_drand48_data fixed" missing prototype of __libc_drand48_data fixed time.c, time.h: remove unused hidden strftime/strptime nanosleep.c: remove duplicated libc_hidden_proto ctype.c, ctype.h: remove commented parts that were banned for removal after 0.9.31 _wctype.c, wctype.h: remove unused isw* and wctype_l hidden functions time.c, wchar.h: remove unused hidden wcsftime str[n]casecmp.c: fix hidden usage remove unused hidden functions frv/memset.S: add missing libc_hidden_def ... Conflicts: ldso/ldso/ldso.c Signed-off-by: Carmelo Amoroso <carmelo.amoroso@st.com>
Diffstat (limited to 'libc/sysdeps/linux/c6x/clone.S')
-rw-r--r--libc/sysdeps/linux/c6x/clone.S98
1 files changed, 98 insertions, 0 deletions
diff --git a/libc/sysdeps/linux/c6x/clone.S b/libc/sysdeps/linux/c6x/clone.S
new file mode 100644
index 000000000..6fba5bb98
--- /dev/null
+++ b/libc/sysdeps/linux/c6x/clone.S
@@ -0,0 +1,98 @@
+ ;
+ ; Port of uClibc for TMS320C6000 DSP architecture
+ ; Copyright (C) 2004 Texas Instruments Incorporated
+ ; Author of TMS320C6000 port: Aurelien Jacquiot
+ ;
+ ; This program is free software; you can redistribute it and/or modify it
+ ; under the terms of the GNU Library General Public License as published by
+ ; the Free Software Foundation; either version 2 of the License, or (at your
+ ; option) any later version.
+ ;
+ ; This program 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 Library General Public License
+ ; for more details.
+ ;
+ ; You should have received a copy of the GNU Library General Public License
+ ; along with this program; if not, write to the Free Software Foundation,
+ ; Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ ;
+#define __ASSEMBLY__
+
+ ; int _clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg);
+
+#include <asm/errno.h>
+#include <sys/syscall.h>
+
+ .global __clone
+ .global clone
+ .global __errno_location
+
+ ;Currently supports only
+ ;int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg)
+ ;
+ ;Requires update for supporting
+ ; int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
+ ; int *parent_tidptr, struct user_desc *newtls, int *child_pidptr)
+
+__clone:
+ ; index 1 points to the forth argument and is to be moved to B6
+ LDW .D2T2 *+B15[1],B5
+ NOP 4
+ OR .D2X B4,A4,B2 ; sanity check arguments, no NULL function or stack pointers
+|| MV .S2 B4,B9
+|| MV .D1 A4,A9 ; backup fn and child_stack pointers
+
+ [!B2] B .S2 __syscall_error
+||[!B2] MVK .S1 EINVAL,A4
+ NOP 4
+
+ MV .D1 A6,A4 ; get flags as arg0, arg1 is the new stack
+|| AND .D2 ~7,B4,B4
+
+ ; do the system call
+|| MVK .S2 __NR_clone,B0
+|| MV .L2 B5,B6
+0:
+#ifndef _TMS320C6400_PLUS
+ MVC .S2 CSR,B2
+ CLR .S2 B2,0,0,B1
+ MVC .S2 B1,CSR
+ MVC .S2 IFR,B1
+ SET .S2 B1,6,6,B1
+ MVC .S2 B1,ISR
+ MVC .S2 B2,CSR
+ NOP
+#else
+ SWE
+#endif
+
+ MV .D2 B9,B4 ; restore child stack
+
+|| CMPEQ .L1 0,A4,A2
+|| CMPLT .L2X A4,0,B2
+
+ [B2] B .S2 __syscall_error ; if syscall < 0, it is an error
+ NOP 5
+ [A2] B .S2X A9 ; branch to function
+|| [A2] MV .D1X B6,A4 ; set arg (B6 is preserved by syscall)
+ [!A2] B .S2 B3 ; otherwise (syscall result > 0) returns directly
+ [A2] ADDKPC .S2 __return_thread,B3, 4
+
+__return_thread:
+ b .s2 HIDDEN_JUMPTARGET(_exit)
+ nop 5
+
+__syscall_error:
+ NEG .S1 A4,A4
+ STW .D2T1 A4,*B15--[2]
+ STW .D2T2 B3,*+B15[1]
+ CALLP .S2 __errno_location,B3
+ LDW .D2T2 *+B15[1],B3
+ LDW .D2T1 *++B15[2],A5
+ NOP 3
+ BNOP .S2 B3,3
+ STW .D1T1 A5,*A4
+ MVK .L1 -1,A4
+
+.set clone, __clone