From owner-svn-src-user@FreeBSD.ORG Fri May 15 23:07:46 2009 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D12B910656C5; Fri, 15 May 2009 23:07:46 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 7FD518FC1B; Fri, 15 May 2009 23:07:46 +0000 (UTC) (envelope-from kmacy@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4FN7kPl037154; Fri, 15 May 2009 23:07:46 GMT (envelope-from kmacy@svn.freebsd.org) Received: (from kmacy@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4FN7kF5037150; Fri, 15 May 2009 23:07:46 GMT (envelope-from kmacy@svn.freebsd.org) Message-Id: <200905152307.n4FN7kF5037150@svn.freebsd.org> From: Kip Macy Date: Fri, 15 May 2009 23:07:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192162 - in user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic: amd64 i386 ia64 sparc64 X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 May 2009 23:07:47 -0000 Author: kmacy Date: Fri May 15 23:07:46 2009 New Revision: 192162 URL: http://svn.freebsd.org/changeset/base/192162 Log: rename opensolaris specific atomic functions Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S (contents, props changed) user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S (contents, props changed) Deleted: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/atomic.S user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/atomic.S user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/atomic.S user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/atomic.S Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/amd64/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,66 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + .file "atomic.s" + +#define _ASM +#include + + ENTRY(atomic_add_64_nv) + movq (%rdi), %rax +1: + movq %rsi, %rcx + addq %rax, %rcx + lock + cmpxchgq %rcx, (%rdi) + jne 1b + movq %rcx, %rax + ret + SET_SIZE(atomic_add_64_nv) + + ENTRY(atomic_or_8_nv) + movb (%rdi), %al // %al = old value +1: + movb %sil, %cl + orb %al, %cl // %cl = new value + lock + cmpxchgb %cl, (%rdi) // try to stick it in + jne 1b + movzbl %cl, %eax // return new value + ret + SET_SIZE(atomic_or_8_nv) + + ENTRY(atomic_cas_64) + movq %rsi, %rax + lock + cmpxchgq %rdx, (%rdi) + ret + SET_SIZE(atomic_cas_64) + + ENTRY(membar_producer) + sfence + ret + SET_SIZE(membar_producer) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/i386/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,133 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ + +/* + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + .file "atomic.s" + +#define _ASM +#include + + /* + * NOTE: If atomic_dec_64 and atomic_dec_64_nv are ever + * separated, it is important to edit the libc i386 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_dec_64_nv. + */ + ENTRY(atomic_dec_64) + ALTENTRY(atomic_dec_64_nv) + pushl %edi + pushl %ebx + movl 12(%esp), %edi // %edi = target address + movl (%edi), %eax + movl 4(%edi), %edx // %edx:%eax = old value +1: + xorl %ebx, %ebx + xorl %ecx, %ecx + not %ecx + not %ebx // %ecx:%ebx = -1 + addl %eax, %ebx + adcl %edx, %ecx // add in the carry from inc + lock + cmpxchg8b (%edi) // try to stick it in + jne 1b + movl %ebx, %eax + movl %ecx, %edx // return new value + popl %ebx + popl %edi + ret + SET_SIZE(atomic_dec_64_nv) + SET_SIZE(atomic_dec_64) + + /* + * NOTE: If atomic_add_64 and atomic_add_64_nv are ever + * separated, it is important to edit the libc i386 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_add_64_nv. + */ + ENTRY(atomic_add_64) + ALTENTRY(atomic_add_64_nv) + pushl %edi + pushl %ebx + movl 12(%esp), %edi // %edi = target address + movl (%edi), %eax + movl 4(%edi), %edx // %edx:%eax = old value +1: + movl 16(%esp), %ebx + movl 20(%esp), %ecx // %ecx:%ebx = delta + addl %eax, %ebx + adcl %edx, %ecx // %ecx:%ebx = new value + lock + cmpxchg8b (%edi) // try to stick it in + jne 1b + movl %ebx, %eax + movl %ecx, %edx // return new value + popl %ebx + popl %edi + ret + SET_SIZE(atomic_add_64_nv) + SET_SIZE(atomic_add_64) + + ENTRY(atomic_or_8_nv) + movl 4(%esp), %edx // %edx = target address + movb (%edx), %al // %al = old value +1: + movl 8(%esp), %ecx // %ecx = delta + orb %al, %cl // %cl = new value + lock + cmpxchgb %cl, (%edx) // try to stick it in + jne 1b + movzbl %cl, %eax // return new value + ret + SET_SIZE(atomic_or_8_nv) + + ENTRY(atomic_cas_ptr) + movl 4(%esp), %edx + movl 8(%esp), %eax + movl 12(%esp), %ecx + lock + cmpxchgl %ecx, (%edx) + ret + SET_SIZE(atomic_cas_ptr) + + ENTRY(atomic_cas_64) + pushl %ebx + pushl %esi + movl 12(%esp), %esi + movl 16(%esp), %eax + movl 20(%esp), %edx + movl 24(%esp), %ebx + movl 28(%esp), %ecx + lock + cmpxchg8b (%esi) + popl %esi + popl %ebx + ret + SET_SIZE(atomic_cas_64) + + ENTRY(membar_producer) + lock + xorl $0, (%esp) + ret + SET_SIZE(membar_producer) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/ia64/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,82 @@ +/*- + * Copyright (c) 2007 Marcel Moolenaar + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * $FreeBSD$ + */ + +#include + + .text + +/* + * uint64_t atomic_cas_64(volatile uint64_t *p, uint64_t cmp, uint64_t v) + */ +ENTRY(atomic_cas_64, 3) + mov ar.ccv = r33 + ;; + cmpxchg8.acq r8 = [r32], r34, ar.ccv + ;; + br.ret.sptk rp +END(atomic_cas_64) + +/* + * uint64_t atomic_add_64_nv(volatile uint64_t *p, uint64_t v) + */ +ENTRY(atomic_add_64_nv, 2) +1: + ld8 r16 = [r32] + ;; + mov ar.ccv = r16 + add r8 = r16, r33 + ;; + cmpxchg8.acq r17 = [r32], r8, ar.ccv + ;; + cmp.eq p6, p7 = r16, r17 +(p6) br.ret.sptk rp +(p7) br.cond.spnt 1b +END(atomic_add_64_nv) + +/* + * uint8_t atomic_or_8_nv(volatile uint8_t *p, uint8_t v) + */ +ENTRY(atomic_or_8_nv, 2) +1: + ld8 r16 = [r32] + ;; + mov ar.ccv = r16 + or r8 = r16, r33 + ;; + cmpxchg1.acq r17 = [r32], r8, ar.ccv + ;; + cmp.eq p6, p7 = r16, r17 +(p6) br.ret.sptk rp +(p7) br.cond.spnt 1b +END(atomic_or_8_nv) + +ENTRY(membar_producer, 0) + mf.a + ;; + br.ret.sptk rp +END(membar_producer) Added: user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ user/kmacy/ZFS_MFC/sys/cddl/contrib/opensolaris/common/atomic/sparc64/opensolaris_atomic.S Fri May 15 23:07:46 2009 (r192162) @@ -0,0 +1,115 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (the "License"). + * You may not use this file except in compliance with the License. + * + * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE + * or http://www.opensolaris.org/os/licensing. + * See the License for the specific language governing permissions + * and limitations under the License. + * + * When distributing Covered Code, include this CDDL HEADER in each + * file and include the License file at usr/src/OPENSOLARIS.LICENSE. + * If applicable, add the following below this CDDL HEADER, with the + * fields enclosed by brackets "[]" replaced with your own identifying + * information: Portions Copyright [yyyy] [name of copyright owner] + * + * CDDL HEADER END + */ +/* + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + + .ident "%Z%%M% %I% %E% SMI" + + .file "%M%" + +#define _ASM +#include + +#include + +/* Userland needs different ASIs. */ +#ifdef _KERNEL +#define __ASI_ATOMIC ASI_N +#else +#define __ASI_ATOMIC ASI_P +#endif + + /* + * NOTE: If atomic_add_64 and atomic_add_64_nv are ever + * separated, you need to also edit the libc sparcv9 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_add_64_nv. + */ + ENTRY(atomic_add_64) + ALTENTRY(atomic_add_64_nv) + ALTENTRY(atomic_add_ptr) + ALTENTRY(atomic_add_ptr_nv) + ALTENTRY(atomic_add_long) + ALTENTRY(atomic_add_long_nv) +add_64: + ldx [%o0], %o2 +1: + add %o2, %o1, %o3 + casxa [%o0] __ASI_ATOMIC, %o2, %o3 + cmp %o2, %o3 + bne,a,pn %xcc, 1b + mov %o3, %o2 + retl + add %o2, %o1, %o0 ! return new value + SET_SIZE(atomic_add_long_nv) + SET_SIZE(atomic_add_long) + SET_SIZE(atomic_add_ptr_nv) + SET_SIZE(atomic_add_ptr) + SET_SIZE(atomic_add_64_nv) + SET_SIZE(atomic_add_64) + + /* + * NOTE: If atomic_or_8 and atomic_or_8_nv are ever + * separated, you need to also edit the libc sparcv9 platform + * specific mapfile and remove the NODYNSORT attribute + * from atomic_or_8_nv. + */ + ENTRY(atomic_or_8) + ALTENTRY(atomic_or_8_nv) + ALTENTRY(atomic_or_uchar) + ALTENTRY(atomic_or_uchar_nv) + and %o0, 0x3, %o4 ! %o4 = byte offset, left-to-right + xor %o4, 0x3, %g1 ! %g1 = byte offset, right-to-left + sll %g1, 3, %g1 ! %g1 = bit offset, right-to-left + set 0xff, %o3 ! %o3 = mask + sll %o3, %g1, %o3 ! %o3 = shifted to bit offset + sll %o1, %g1, %o1 ! %o1 = shifted to bit offset + and %o1, %o3, %o1 ! %o1 = single byte value + andn %o0, 0x3, %o0 ! %o0 = word address + ld [%o0], %o2 ! read old value +1: + or %o2, %o1, %o5 ! or in the new value + casa [%o0] __ASI_ATOMIC, %o2, %o5 + cmp %o2, %o5 + bne,a,pn %icc, 1b + mov %o5, %o2 ! %o2 = old value + or %o2, %o1, %o5 + and %o5, %o3, %o5 + retl + srl %o5, %g1, %o0 ! %o0 = new value + SET_SIZE(atomic_or_uchar_nv) + SET_SIZE(atomic_or_uchar) + SET_SIZE(atomic_or_8_nv) + SET_SIZE(atomic_or_8) + + /* + * Spitfires and Blackbirds have a problem with membars in the + * delay slot (SF_ERRATA_51). For safety's sake, we assume + * that the whole world needs the workaround. + */ + + ENTRY(membar_producer) + membar #StoreStore + retl + nop + SET_SIZE(membar_producer)