xref: /dflybsd-src/sys/dev/drm/include/asm/atomic.h (revision ab413216e0477d18360cae566110a40c280c86b8)
1a05eeebfSFrançois Tigeot /*
263aa39b7SFrançois Tigeot  * Copyright (c) 2016-2019 François Tigeot <ftigeot@wolfpond.org>
3a05eeebfSFrançois Tigeot  * All rights reserved.
4a05eeebfSFrançois Tigeot  *
5a05eeebfSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6a05eeebfSFrançois Tigeot  * modification, are permitted provided that the following conditions
7a05eeebfSFrançois Tigeot  * are met:
8a05eeebfSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9a05eeebfSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10a05eeebfSFrançois Tigeot  *    disclaimer.
11a05eeebfSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12a05eeebfSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13a05eeebfSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14a05eeebfSFrançois Tigeot  *
15a05eeebfSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16a05eeebfSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17a05eeebfSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18a05eeebfSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19a05eeebfSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20a05eeebfSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21a05eeebfSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22a05eeebfSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23a05eeebfSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24a05eeebfSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25a05eeebfSFrançois Tigeot  */
26a05eeebfSFrançois Tigeot 
27a05eeebfSFrançois Tigeot #ifndef _ASM_ATOMIC_H_
28a05eeebfSFrançois Tigeot #define _ASM_ATOMIC_H_
29a05eeebfSFrançois Tigeot 
30*ab413216SFrançois Tigeot #include <linux/compiler.h>
31*ab413216SFrançois Tigeot #include <linux/types.h>
32*ab413216SFrançois Tigeot #include <asm/cmpxchg.h>
33*ab413216SFrançois Tigeot #include <asm/barrier.h>
34*ab413216SFrançois Tigeot 
35a05eeebfSFrançois Tigeot /* atomic_or: atomically set bits in a variable */
36a05eeebfSFrançois Tigeot #define atomic_or(mask, addr)		\
37a05eeebfSFrançois Tigeot 	/* atomic *addr |= mask; */		\
38a05eeebfSFrançois Tigeot 	__asm __volatile("lock orl %0, %1"	\
39a05eeebfSFrançois Tigeot 		:				\
40a05eeebfSFrançois Tigeot 		: "r" (mask), "m" (*addr)	\
41a05eeebfSFrançois Tigeot 		: "memory");
42a05eeebfSFrançois Tigeot 
4363aa39b7SFrançois Tigeot #define ATOMIC_INIT(i)	{ (i) }
4463aa39b7SFrançois Tigeot 
45ed51adf4SFrançois Tigeot #include <asm/atomic64_64.h>
46ed51adf4SFrançois Tigeot 
47a05eeebfSFrançois Tigeot #endif	/* _ASM_ATOMIC_H_ */
48