1/* $OpenBSD: tfork_thread.S,v 1.6 2020/10/19 17:57:40 naddy 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#include <sys/syscall.h> 18#include <machine/asm.h> 19#include "SYS.h" 20 21/* 22 * r0 r1 r2 r3 23 * __tfork_thread(param, psize, start_fnc, start_arg); 24 */ 25 26ENTRY(__tfork_thread) 27 .cfi_startproc 28 RETGUARD_SETUP(__tfork_thread, x15) 29 SYSTRAP(__tfork) 30 .cfi_endproc 31 bcs CERROR 32 33 /* check if we are parent or child */ 34 cbz x0, 1f 35 RETGUARD_CHECK(__tfork_thread, x15) 36 ret 37 381: 39 .cfi_startproc 40 .cfi_undefined lr 41 /* child */ 42 ldr fp, 0 43 mov x0, x3 44 blr x2 45 SYSTRAP(__threxit) 46 udf #0 47 .cfi_endproc 48END(__tfork_thread) 49