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