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