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