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