Home | History | Annotate | Line # | Download | only in atomic
      1 /*	$NetBSD: atomic_nand.S,v 1.3 2022/04/06 22:47:56 riastradh 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 
     36 ENTRY(_atomic_nand_32_nv)
     37 	movl	4(%sp), %a0
     38 1:	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
     46 END(_atomic_nand_32_nv)
     47 ATOMIC_OP_ALIAS(atomic_nand_32_nv,_atomic_nand_32_nv)
     48 ATOMIC_OP_ALIAS(atomic_nand_uint_nv,_atomic_nand_32_nv)
     49 STRONG_ALIAS(_atomic_nand_uint_nv,_atomic_nand_32_nv)
     50 ATOMIC_OP_ALIAS(atomic_nand_ulong_nv,_atomic_nand_32_nv)
     51 STRONG_ALIAS(_atomic_nand_ulong_nv,_atomic_nand_32_nv)
     52 ATOMIC_OP_ALIAS(atomic_nand_ptr_nv,_atomic_nand_32_nv)
     53 STRONG_ALIAS(_atomic_nand_ptr_nv,_atomic_nand_32_nv)
     54 ATOMIC_OP_ALIAS(atomic_nand_32,_atomic_nand_32_nv)
     55 ATOMIC_OP_ALIAS(atomic_nand_uint,_atomic_nand_32_nv)
     56 STRONG_ALIAS(_atomic_nand_uint,_atomic_nand_32_nv)
     57 ATOMIC_OP_ALIAS(atomic_nand_ulong,_atomic_nand_32_nv)
     58 STRONG_ALIAS(_atomic_nand_ulong,_atomic_nand_32_nv)
     59 ATOMIC_OP_ALIAS(atomic_nand_ptr,_atomic_nand_32_nv)
     60 STRONG_ALIAS(_atomic_nand_ptr,_atomic_nand_32_nv)
     61 CRT_ALIAS(__sync_nand_and_fetch_4,_atomic_nand_32_nv)
     62 
     63 ENTRY(__sync_fetch_and_nand_4)
     64 	movl	4(%sp), %a0
     65 1:	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
     73 END(__sync_fetch_and_nand_4)
     74 
     75 
     76 ENTRY(_atomic_nand_16_nv)
     77 	movl	4(%sp), %a0
     78 1:	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
     85 END(_atomic_nand_16_nv)
     86 
     87 CRT_ALIAS(__sync_nand_and_fetch_2,_atomic_nand_16_nv)
     88 
     89 ENTRY(__sync_fetch_and_nand_2)
     90 	movl	4(%sp), %a0
     91 1:	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
     98 END(__sync_fetch_and_nand_2)
     99 
    100 
    101 ENTRY(_atomic_nand_8_nv)
    102 	movl	4(%sp), %a0
    103 1:	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
    110 END(_atomic_nand_8_nv)
    111 
    112 CRT_ALIAS(__sync_nand_and_fetch_1,_atomic_nand_8_nv)
    113 
    114 ENTRY(__sync_fetch_and_nand_1)
    115 	movl	4(%sp), %a0
    116 1:	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
    123 END(__sync_fetch_and_nand_1)
    124