1/* $OpenBSD: tfork_thread.S,v 1.7 2022/05/24 17:20:23 guenther Exp $ */
2/*
3 * Copyright (c) 2005 Dale Rahn <drahn@openbsd.org>
4 *
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
8 *
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16 */
17
18#include "SYS.h"
19
20/*
21 *                r0     r1     r2         r3
22 * __tfork_thread(param, psize, start_fnc, start_arg);
23 */
24
25ENTRY(__tfork_thread)
26	SYSTRAP(__tfork)
27	bcs	CERROR
28
29	/* check if we are parent or child */
30	cmp	r0, #0
31	movne	pc, lr
32
33	/* child */
34	mov	r0, r3
35	mov	lr, pc
36	mov	pc, r2
37	nop
38	SYSTRAP(__threxit)
39	udf	#0
40END(__tfork_thread)
41