1*2d9adf0dSmatt/* $NetBSD: atomic_nand_32.S,v 1.2 2015/03/27 06:42:37 matt Exp $ */ 26cf6fe02Smatt/*- 36cf6fe02Smatt * Copyright (c) 2014 The NetBSD Foundation, Inc. 46cf6fe02Smatt * All rights reserved. 56cf6fe02Smatt * 66cf6fe02Smatt * This code is derived from software contributed to The NetBSD Foundation 76cf6fe02Smatt * by Matt Thomas <matt@3am-software.com> 86cf6fe02Smatt * 96cf6fe02Smatt * Redistribution and use in source and binary forms, with or without 106cf6fe02Smatt * modification, are permitted provided that the following conditions 116cf6fe02Smatt * are met: 126cf6fe02Smatt * 1. Redistributions of source code must retain the above copyright 136cf6fe02Smatt * notice, this list of conditions and the following disclaimer. 146cf6fe02Smatt * 2. Redistributions in binary form must reproduce the above copyright 156cf6fe02Smatt * notice, this list of conditions and the following disclaimer in the 166cf6fe02Smatt * documentation and/or other materials provided with the distribution. 176cf6fe02Smatt * 186cf6fe02Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 196cf6fe02Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 206cf6fe02Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 216cf6fe02Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 226cf6fe02Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 236cf6fe02Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 246cf6fe02Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 256cf6fe02Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 266cf6fe02Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 276cf6fe02Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 286cf6fe02Smatt * POSSIBILITY OF SUCH DAMAGE. 296cf6fe02Smatt */ 306cf6fe02Smatt 316cf6fe02Smatt#include "atomic_op_asm.h" 326cf6fe02Smatt 336cf6fe02SmattENTRY_NP(_atomic_nand_32) 34*2d9adf0dSmatt mv t0, a0 35*2d9adf0dSmatt1: lr.w a0, 0(t0) 36*2d9adf0dSmatt not t2, a0 37*2d9adf0dSmatt and t2, t2, a1 38*2d9adf0dSmatt sc.w t1, t2, 0(t0) 39*2d9adf0dSmatt bnez t1, 1b 406cf6fe02Smatt ret 416cf6fe02SmattEND(_atomic_nand_32) 426cf6fe02Smatt 436cf6fe02SmattATOMIC_OP_ALIAS(atomic_nand_32,_atomic_nand_32) 446cf6fe02SmattATOMIC_OP_ALIAS(atomic_nand_uint,_atomic_nand_32) 456cf6fe02SmattSTRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32) 466cf6fe02Smatt#ifndef _LP64 476cf6fe02SmattATOMIC_OP_ALIAS(atomic_nand_ulong,_atomic_nand_32) 486cf6fe02SmattSTRONG_ALIAS(_atomic_nand_ulong,_atomic_nand_32) 496cf6fe02Smatt#endif 506cf6fe02SmattCRT_ALIAS(__sync_fetch_and_nand_4,_atomic_nand_32) 516cf6fe02SmattCRT_ALIAS(__atomic_fetch_nand_4,_atomic_nand_32) 526cf6fe02Smatt 536cf6fe02SmattENTRY_NP(_atomic_nand_32_nv) 54*2d9adf0dSmatt mv t0, a0 55*2d9adf0dSmatt1: lr.w a0, 0(t0) 56*2d9adf0dSmatt not a0, a0 57*2d9adf0dSmatt and a0, a0, a1 58*2d9adf0dSmatt sc.w t1, a0, 0(t0) 59*2d9adf0dSmatt bnez t1, 1b 606cf6fe02Smatt ret 616cf6fe02SmattEND(_atomic_nand_32_nv) 626cf6fe02Smatt 636cf6fe02SmattATOMIC_OP_ALIAS(atomic_nand_32_nv,_atomic_nand_32_nv) 646cf6fe02SmattATOMIC_OP_ALIAS(atomic_nand_uint_nv,_atomic_nand_32_nv) 656cf6fe02SmattSTRONG_ALIAS(_atomic_nand_uint_nv,_atomic_nand_32_nv) 666cf6fe02Smatt#ifndef _LP64 676cf6fe02SmattATOMIC_OP_ALIAS(atomic_nand_ulong_nv,_atomic_nand_32_nv) 686cf6fe02SmattSTRONG_ALIAS(_atomic_nand_ulong_nv,_atomic_nand_32_nv) 696cf6fe02Smatt#endif 706cf6fe02SmattCRT_ALIAS(__sync_nand_and_fetch_4,_atomic_nand_32_nv) 716cf6fe02SmattCRT_ALIAS(__atomic_nand_fetch_4,_atomic_nand_32_nv) 72