1*0a6a1f1dSLionel Sambuc/* $NetBSD: atomic_nand.S,v 1.2 2014/02/22 17:08:30 martin Exp $ */ 2*0a6a1f1dSLionel Sambuc 3*0a6a1f1dSLionel Sambuc/*- 4*0a6a1f1dSLionel Sambuc * Copyright (c) 2007 The NetBSD Foundation, Inc. 5*0a6a1f1dSLionel Sambuc * All rights reserved. 6*0a6a1f1dSLionel Sambuc * 7*0a6a1f1dSLionel Sambuc * This code is derived from software contributed to The NetBSD Foundation 8*0a6a1f1dSLionel Sambuc * by Jason R. Thorpe. 9*0a6a1f1dSLionel Sambuc * 10*0a6a1f1dSLionel Sambuc * Redistribution and use in source and binary forms, with or without 11*0a6a1f1dSLionel Sambuc * modification, are permitted provided that the following conditions 12*0a6a1f1dSLionel Sambuc * are met: 13*0a6a1f1dSLionel Sambuc * 1. Redistributions of source code must retain the above copyright 14*0a6a1f1dSLionel Sambuc * notice, this list of conditions and the following disclaimer. 15*0a6a1f1dSLionel Sambuc * 2. Redistributions in binary form must reproduce the above copyright 16*0a6a1f1dSLionel Sambuc * notice, this list of conditions and the following disclaimer in the 17*0a6a1f1dSLionel Sambuc * documentation and/or other materials provided with the distribution. 18*0a6a1f1dSLionel Sambuc * 19*0a6a1f1dSLionel Sambuc * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 20*0a6a1f1dSLionel Sambuc * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 21*0a6a1f1dSLionel Sambuc * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22*0a6a1f1dSLionel Sambuc * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 23*0a6a1f1dSLionel Sambuc * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 24*0a6a1f1dSLionel Sambuc * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 25*0a6a1f1dSLionel Sambuc * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 26*0a6a1f1dSLionel Sambuc * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 27*0a6a1f1dSLionel Sambuc * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 28*0a6a1f1dSLionel Sambuc * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 29*0a6a1f1dSLionel Sambuc * POSSIBILITY OF SUCH DAMAGE. 30*0a6a1f1dSLionel Sambuc */ 31*0a6a1f1dSLionel Sambuc 32*0a6a1f1dSLionel Sambuc#include "atomic_op_asm.h" 33*0a6a1f1dSLionel Sambuc 34*0a6a1f1dSLionel Sambuc .text 35*0a6a1f1dSLionel Sambuc 36*0a6a1f1dSLionel SambucENTRY(_atomic_nand_32_nv) 37*0a6a1f1dSLionel Sambuc movl 4(%sp), %a0 38*0a6a1f1dSLionel Sambuc1: movl (%a0), %d0 39*0a6a1f1dSLionel Sambuc movl %d0, %d1 40*0a6a1f1dSLionel Sambuc andl 8(%sp), %d0 41*0a6a1f1dSLionel Sambuc notl %d0 42*0a6a1f1dSLionel Sambuc casl %d1, %d0, (%a0) 43*0a6a1f1dSLionel Sambuc bne 1b 44*0a6a1f1dSLionel Sambuc movl %d0, %a0 45*0a6a1f1dSLionel Sambuc rts 46*0a6a1f1dSLionel SambucEND(_atomic_nand_32_nv) 47*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_32_nv,_atomic_nand_32_nv) 48*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_uint_nv,_atomic_nand_32_nv) 49*0a6a1f1dSLionel SambucSTRONG_ALIAS(_atomic_nand_uint_nv,_atomic_nand_32_nv) 50*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_ulong_nv,_atomic_nand_32_nv) 51*0a6a1f1dSLionel SambucSTRONG_ALIAS(_atomic_nand_ulong_nv,_atomic_nand_32_nv) 52*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_ptr_nv,_atomic_nand_32_nv) 53*0a6a1f1dSLionel SambucSTRONG_ALIAS(_atomic_nand_ptr_nv,_atomic_nand_32_nv) 54*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_32,_atomic_nand_32_nv) 55*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_uint,_atomic_nand_32_nv) 56*0a6a1f1dSLionel SambucSTRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32_nv) 57*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_ulong,_atomic_nand_32_nv) 58*0a6a1f1dSLionel SambucSTRONG_ALIAS(_atomic_nand_ulong,_atomic_nand_32_nv) 59*0a6a1f1dSLionel SambucATOMIC_OP_ALIAS(atomic_nand_ptr,_atomic_nand_32_nv) 60*0a6a1f1dSLionel SambucSTRONG_ALIAS(_atomic_nand_ptr,_atomic_nand_32_nv) 61*0a6a1f1dSLionel SambucCRT_ALIAS(__sync_nand_and_fetch_4,_atomic_nand_32_nv) 62*0a6a1f1dSLionel Sambuc 63*0a6a1f1dSLionel SambucENTRY(__sync_fetch_and_nand_4) 64*0a6a1f1dSLionel Sambuc movl 4(%sp), %a0 65*0a6a1f1dSLionel Sambuc1: movl (%a0), %d0 66*0a6a1f1dSLionel Sambuc movl %d0, %d1 67*0a6a1f1dSLionel Sambuc andl 8(%sp), %d1 68*0a6a1f1dSLionel Sambuc notl %d1 69*0a6a1f1dSLionel Sambuc casl %d0, %d1, (%a0) 70*0a6a1f1dSLionel Sambuc bne 1b 71*0a6a1f1dSLionel Sambuc movl %d0, %a0 72*0a6a1f1dSLionel Sambuc rts 73*0a6a1f1dSLionel SambucEND(__sync_fetch_and_nand_4) 74*0a6a1f1dSLionel Sambuc 75*0a6a1f1dSLionel Sambuc 76*0a6a1f1dSLionel SambucENTRY(_atomic_nand_16_nv) 77*0a6a1f1dSLionel Sambuc movl 4(%sp), %a0 78*0a6a1f1dSLionel Sambuc1: movw (%a0), %d0 79*0a6a1f1dSLionel Sambuc movw %d0, %d1 80*0a6a1f1dSLionel Sambuc andw 8(%sp), %d0 81*0a6a1f1dSLionel Sambuc notw %d0 82*0a6a1f1dSLionel Sambuc casw %d1, %d0, (%a0) 83*0a6a1f1dSLionel Sambuc bne 1b 84*0a6a1f1dSLionel Sambuc rts 85*0a6a1f1dSLionel SambucEND(_atomic_nand_16_nv) 86*0a6a1f1dSLionel Sambuc 87*0a6a1f1dSLionel SambucCRT_ALIAS(__sync_nand_and_fetch_2,_atomic_nand_16_nv) 88*0a6a1f1dSLionel Sambuc 89*0a6a1f1dSLionel SambucENTRY(__sync_fetch_and_nand_2) 90*0a6a1f1dSLionel Sambuc movl 4(%sp), %a0 91*0a6a1f1dSLionel Sambuc1: movw (%a0), %d0 92*0a6a1f1dSLionel Sambuc movw %d0, %d1 93*0a6a1f1dSLionel Sambuc andw 8(%sp), %d1 94*0a6a1f1dSLionel Sambuc notw %d1 95*0a6a1f1dSLionel Sambuc casw %d0, %d1, (%a0) 96*0a6a1f1dSLionel Sambuc bne 1b 97*0a6a1f1dSLionel Sambuc rts 98*0a6a1f1dSLionel SambucEND(__sync_fetch_and_nand_2) 99*0a6a1f1dSLionel Sambuc 100*0a6a1f1dSLionel Sambuc 101*0a6a1f1dSLionel SambucENTRY(_atomic_nand_8_nv) 102*0a6a1f1dSLionel Sambuc movl 4(%sp), %a0 103*0a6a1f1dSLionel Sambuc1: movb (%a0), %d0 104*0a6a1f1dSLionel Sambuc movb %d0, %d1 105*0a6a1f1dSLionel Sambuc andb 8(%sp), %d0 106*0a6a1f1dSLionel Sambuc notb %d0 107*0a6a1f1dSLionel Sambuc casb %d1, %d0, (%a0) 108*0a6a1f1dSLionel Sambuc bne 1b 109*0a6a1f1dSLionel Sambuc rts 110*0a6a1f1dSLionel SambucEND(_atomic_nand_8_nv) 111*0a6a1f1dSLionel Sambuc 112*0a6a1f1dSLionel SambucCRT_ALIAS(__sync_nand_and_fetch_1,_atomic_nand_8_nv) 113*0a6a1f1dSLionel Sambuc 114*0a6a1f1dSLionel SambucENTRY(__sync_fetch_and_nand_1) 115*0a6a1f1dSLionel Sambuc movl 4(%sp), %a0 116*0a6a1f1dSLionel Sambuc1: movb (%a0), %d0 117*0a6a1f1dSLionel Sambuc movb %d0, %d1 118*0a6a1f1dSLionel Sambuc andb 8(%sp), %d1 119*0a6a1f1dSLionel Sambuc notb %d1 120*0a6a1f1dSLionel Sambuc casb %d0, %d1, (%a0) 121*0a6a1f1dSLionel Sambuc bne 1b 122*0a6a1f1dSLionel Sambuc rts 123*0a6a1f1dSLionel SambucEND(__sync_fetch_and_nand_1) 124