1*0f2255fcSdrahn/* $OpenBSD: tfork_thread.S,v 1.2 2021/05/04 04:26:00 drahn Exp $ */ 27ecb72feSdrahn/* 37ecb72feSdrahn * Copyright (c) 2020 Brian Bamsch <bbamsch@google.com> 47ecb72feSdrahn * All rights reserved. 57ecb72feSdrahn * 67ecb72feSdrahn * Redistribution and use in source and binary forms, with or without 77ecb72feSdrahn * modification, are permitted provided that the following conditions 87ecb72feSdrahn * are met: 97ecb72feSdrahn * 1. Redistributions of source code must retain the above copyright 107ecb72feSdrahn * notice, this list of conditions and the following disclaimer. 117ecb72feSdrahn * 2. Redistributions in binary form must reproduce the above copyright 127ecb72feSdrahn * notice, this list of conditions and the following disclaimer in the 137ecb72feSdrahn * documentation and/or other materials provided with the distribution. 147ecb72feSdrahn * 3. Neither the name of the copyright holder nor the names of contributors 157ecb72feSdrahn * may be used to endorse or promote products derived from this software 167ecb72feSdrahn * without specific prior written permission. 177ecb72feSdrahn * 187ecb72feSdrahn * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTOR(S) ``AS IS'' AND 197ecb72feSdrahn * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 207ecb72feSdrahn * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 217ecb72feSdrahn * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTOR(S) BE LIABLE 227ecb72feSdrahn * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 237ecb72feSdrahn * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 247ecb72feSdrahn * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 257ecb72feSdrahn * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 267ecb72feSdrahn * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 277ecb72feSdrahn * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 287ecb72feSdrahn * SUCH DAMAGE. 297ecb72feSdrahn */ 307ecb72feSdrahn 317ecb72feSdrahn#include "SYS.h" 327ecb72feSdrahn 337ecb72feSdrahn/* 347ecb72feSdrahn * a0 a1 a2 a3 357ecb72feSdrahn * __tfork_thread(param, psize, start_fnc, start_arg); 367ecb72feSdrahn */ 377ecb72feSdrahn 387ecb72feSdrahnENTRY(__tfork_thread) 397ecb72feSdrahn RETGUARD_SETUP(__tfork_thread, t6) 407ecb72feSdrahn SYSTRAP(__tfork) 41*0f2255fcSdrahn HANDLE_ERROR_TARGET(2f) 427ecb72feSdrahn 437ecb72feSdrahn beqz a0, 1f 447ecb72feSdrahn /* parent thread */ 45*0f2255fcSdrahn2: 467ecb72feSdrahn RETGUARD_CHECK(__tfork_thread, t6) 477ecb72feSdrahn ret 487ecb72feSdrahn 497ecb72feSdrahn1: /* child thread */ 507ecb72feSdrahn mv a0, a3 517ecb72feSdrahn jalr a2 527ecb72feSdrahn SYSTRAP(__threxit) 537ecb72feSdrahnEND(__tfork_thread) 54