opensolaris_atomic.S revision 210193
1/*- 2 * Copyright (C) 2010 Nathan Whitehorn 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright 9 * notice, this list of conditions and the following disclaimer. 10 * 2. Redistributions in binary form must reproduce the above copyright 11 * notice, this list of conditions and the following disclaimer in the 12 * documentation and/or other materials provided with the distribution. 13 * 14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17 * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 18 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 20 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 21 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 22 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 23 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * 25 * $FreeBSD: head/sys/cddl/contrib/opensolaris/common/atomic/powerpc64/opensolaris_atomic.S 210193 2010-07-17 13:34:01Z nwhitehorn $ 26 */ 27 28#include <machine/asm.h> 29 30ENTRY(atomic_add_64_nv) 31 1: ldarx %r5,0,%r3 32 add %r5,%r4,%r5 33 stdcx. %r5,0,%r3 34 bne- 1b 35 36 mr %r3,%r5 37 blr 38 39ENTRY(atomic_cas_64) 40 1: ldarx %r6,0,%r3 41 cmpld %r6,%r4 42 bne 2f 43 stdcx. %r5,0,%r3 44 bne- 1b 45 b 3f 46 47 2: stdcx. %r6,0,%r3 /* clear reservation */ 48 49 3: mr %r3,%r6 50 blr 51 52ENTRY(atomic_or_8_nv) 53 li %r6,3 54 andc. %r6,%r3,%r6 /* r6 = r3 & ~4 */ 55 addi %r7,%r6,3 56 sub %r7,%r7,%r3 /* offset in r7 */ 57 sldi %r7,%r7,3 /* bits to shift in r7 */ 58 59 rlwinm %r4,%r4,0,24,31 /* mask and rotate the argument */ 60 slw %r4,%r4,%r7 61 62 1: lwarx %r5,0,%r6 63 or %r5,%r4,%r5 64 stwcx. %r5,0,%r6 65 bne- 1b 66 67 srw %r3,%r5,%r7 68 rlwinm %r3,%r3,0,24,31 /* mask return value */ 69 70 blr 71 72ENTRY(membar_producer) 73 eieio 74 blr 75 76