1/*
2 * Port of uClibc for TMS320C6000 DSP architecture
3 * Copyright (C) 2004, 2011 Texas Instruments Incorporated
4 * Author of TMS320C6000 port: Aurelien Jacquiot
5 *
6 *   Use clone syscall: Mark Salter <msalter@redhat.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU Library General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU Library General Public License
19 * along with this program; see the file COPYING.LIB.  If not, see
20 * <http://www.gnu.org/licenses/>.
21 */
22#define __ASSEMBLY__
23
24#include <asm/errno.h>
25#include <sys/syscall.h>
26#include <linux/sched.h>
27#include <asm/signal.h>
28
29#define CLONE_FLAGS (CLONE_VFORK | CLONE_VM | SIGCHLD)
30
31	.global __vfork
32__vfork:
33	MVK	.S2	SYS_clone,B0
34 ||	MVKL	.S1	CLONE_FLAGS,A4
35	MVKH	.S1	CLONE_FLAGS,A4
36 ||	MVK	.L2	0,B4
37#ifndef	_TMS320C6400_PLUS
38	MVC	.S2	CSR,B2
39	CLR	.S2	B2,0,0,B1
40	MVC	.S2	B1,CSR
41	MVC	.S2	IFR,B1
42	SET	.S2	B1,6,6,B1
43	MVC	.S2	B1,ISR
44	MVC	.S2	B2,CSR
45	NOP
46#else
47	SWE
48#endif
49
50	MVK	.S2	-4096,B4
51	CMPGTU	.L2X	B4,A4,B2	; check error
52  [B2]	BNOP	.S2	B3,5
53
54	NEG	.S1	A4,A4
55	STW	.D2T1	A4,*B15--[2]
56	STW	.D2T2	B3,*+B15[1]
57	CALLP	.S2	__errno_location,B3
58	LDW	.D2T2	*+B15[1],B3
59	LDW	.D2T1	*++B15[2],A5
60	NOP	3
61	BNOP	.S2	B3,3
62	STW	.D1T1	A5,*A4
63	MVK	.L1	-1,A4
64
65weak_alias(__vfork,vfork)
66libc_hidden_weak(vfork)
67