blob: c93694586f74f0e5061d821a1c5eb73004216bdb [file] [log] [blame]
Raghu Gandham405b8022012-07-25 18:16:42 -07001/*
2 * Copyright (C) 2008 The Android Open Source Project
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in
12 * the documentation and/or other materials provided with the
13 * distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
18 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
19 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
20 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
21 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
22 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
25 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
Raghu Gandham405b8022012-07-25 18:16:42 -070028
Chris Dearman645d0312014-02-05 18:51:43 -080029#include <machine/asm.h>
30#include <asm/unistd.h>
31#include <linux/sched.h>
32
33// TODO: mips' uapi signal.h is missing #ifndef __ASSEMBLY__.
34// #include <asm/signal.h>
35#define SIGCHLD 18
36
37 .text
38
39#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
40FRAMESZ = MKFSIZ(5,0)
41#else
42FRAMESZ = MKFSIZ(0,0)
43#endif
44
45LEAF(vfork,FRAMESZ)
46#if FRAMESZ!=0
47 PTR_SUBU sp, FRAMESZ
48#endif
49 SETUP_GP64(a5,vfork)
50 LI a0, (CLONE_VM | CLONE_VFORK | SIGCHLD)
51 move a1, $0
52 move a2, $0
53 move a3, $0
54#if (_MIPS_SIM == _ABIO32) || (_MIPS_SIM == _ABI32)
55 REG_S $0, 4*REGSZ(sp)
56#else
57 move a4, $0
58#endif
59 LI v0, __NR_clone
60 syscall
61#if FRAMESZ!=0
62 PTR_ADDU sp,FRAMESZ
63#endif
64 move a0, v0
65 bnez a3, 1f
66 RESTORE_GP64
67 j ra
681:
69 LA t9,__set_errno
70 RESTORE_GP64
71 j t9
72 END(vfork)