1*09ff5f3bSriastradh/* $NetBSD: atomic_swap.S,v 1.9 2022/04/06 22:47:56 riastradh Exp $ */ 2bc7bf35cSad 3bc7bf35cSad/*- 4bc7bf35cSad * Copyright (c) 2007 The NetBSD Foundation, Inc. 5bc7bf35cSad * All rights reserved. 6bc7bf35cSad * 7bc7bf35cSad * This code is derived from software contributed to The NetBSD Foundation 8bc7bf35cSad * by Jason R. Thorpe. 9bc7bf35cSad * 10bc7bf35cSad * Redistribution and use in source and binary forms, with or without 11bc7bf35cSad * modification, are permitted provided that the following conditions 12bc7bf35cSad * are met: 13bc7bf35cSad * 1. Redistributions of source code must retain the above copyright 14bc7bf35cSad * notice, this list of conditions and the following disclaimer. 15bc7bf35cSad * 2. Redistributions in binary form must reproduce the above copyright 16bc7bf35cSad * notice, this list of conditions and the following disclaimer in the 17bc7bf35cSad * documentation and/or other materials provided with the distribution. 18bc7bf35cSad * 19bc7bf35cSad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20bc7bf35cSad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21bc7bf35cSad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22bc7bf35cSad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23bc7bf35cSad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24bc7bf35cSad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25bc7bf35cSad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26bc7bf35cSad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27bc7bf35cSad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28bc7bf35cSad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29bc7bf35cSad * POSSIBILITY OF SUCH DAMAGE. 30bc7bf35cSad */ 31bc7bf35cSad 32bc7bf35cSad#include "atomic_op_asm.h" 33bc7bf35cSad 34*09ff5f3bSriastradh__RCSID("$NetBSD: atomic_swap.S,v 1.9 2022/04/06 22:47:56 riastradh Exp $") 35bc7bf35cSad 36cf88c389Smatt .text 376740bb54SchsENTRY(_atomic_swap_32) 386dd4b41fSmatt mr %r10,%r3 396dd4b41fSmatt1: lwarx %r3,0,%r10 40fd255ae5Srin IBM405_ERRATA77_DCBT(0,%r10) 416dd4b41fSmatt stwcx. %r4,0,%r10 426dd4b41fSmatt beqlr+ 436dd4b41fSmatt b 1b 44cf88c389SmattEND(_atomic_swap_32) 45bc7bf35cSadATOMIC_OP_ALIAS(atomic_swap_32,_atomic_swap_32) 466dd4b41fSmatt 47bc7bf35cSadATOMIC_OP_ALIAS(atomic_swap_uint,_atomic_swap_32) 48bc7bf35cSadSTRONG_ALIAS(_atomic_swap_uint,_atomic_swap_32) 496dd4b41fSmatt 506dd4b41fSmatt#if defined(_LP64) 516dd4b41fSmattENTRY(_atomic_swap_64) 526dd4b41fSmatt mr %r10,%r3 536dd4b41fSmatt1: ldarx %r3,0,%r10 546dd4b41fSmatt stdcx. %r4,0,%r10 556dd4b41fSmatt beqlr+ 566dd4b41fSmatt b 1b 576dd4b41fSmattEND(_atomic_swap_64) 586dd4b41fSmattATOMIC_OP_ALIAS(atomic_swap_64,_atomic_swap_64) 596dd4b41fSmatt 606dd4b41fSmattATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_64) 616dd4b41fSmattATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_64) 626dd4b41fSmatt 636dd4b41fSmattSTRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_64) 646dd4b41fSmattSTRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_64) 656dd4b41fSmatt#else 66bc7bf35cSadATOMIC_OP_ALIAS(atomic_swap_ulong,_atomic_swap_32) 67bc7bf35cSadATOMIC_OP_ALIAS(atomic_swap_ptr,_atomic_swap_32) 686dd4b41fSmatt 696dd4b41fSmattSTRONG_ALIAS(_atomic_swap_ulong,_atomic_swap_32) 70bc7bf35cSadSTRONG_ALIAS(_atomic_swap_ptr,_atomic_swap_32) 71bc7bf35cSad#endif 72