xref: /dflybsd-src/sys/dev/drm/include/asm/special_insns.h (revision fc8df11388ff5c5f5e39c0f95296be56cf06e299)
1*fc8df113SFrançois Tigeot /*
2*fc8df113SFrançois Tigeot  * Copyright (c) 2017 François Tigeot
3*fc8df113SFrançois Tigeot  * All rights reserved.
4*fc8df113SFrançois Tigeot  *
5*fc8df113SFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6*fc8df113SFrançois Tigeot  * modification, are permitted provided that the following conditions
7*fc8df113SFrançois Tigeot  * are met:
8*fc8df113SFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9*fc8df113SFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10*fc8df113SFrançois Tigeot  *    disclaimer.
11*fc8df113SFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12*fc8df113SFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13*fc8df113SFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14*fc8df113SFrançois Tigeot  *
15*fc8df113SFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*fc8df113SFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*fc8df113SFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*fc8df113SFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*fc8df113SFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*fc8df113SFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*fc8df113SFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*fc8df113SFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*fc8df113SFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*fc8df113SFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*fc8df113SFrançois Tigeot  */
26*fc8df113SFrançois Tigeot 
27*fc8df113SFrançois Tigeot #ifndef _ASM_SPECIAL_INSNS_H_
28*fc8df113SFrançois Tigeot #define _ASM_SPECIAL_INSNS_H_
29*fc8df113SFrançois Tigeot 
30*fc8df113SFrançois Tigeot static inline void
linux_clflush(volatile void * p)31*fc8df113SFrançois Tigeot linux_clflush(volatile void *p)
32*fc8df113SFrançois Tigeot {
33*fc8df113SFrançois Tigeot 	__asm __volatile("clflush %0" : "+m" (*(volatile char *)p));
34*fc8df113SFrançois Tigeot }
35*fc8df113SFrançois Tigeot 
36*fc8df113SFrançois Tigeot /*
37*fc8df113SFrançois Tigeot  * clflushopt has only been introduced with Skylake (2015) CPUs.
38*fc8df113SFrançois Tigeot  * Do not bother with it for now.
39*fc8df113SFrançois Tigeot  */
40*fc8df113SFrançois Tigeot static inline void
clflushopt(volatile void * p)41*fc8df113SFrançois Tigeot clflushopt(volatile void *p)
42*fc8df113SFrançois Tigeot {
43*fc8df113SFrançois Tigeot 	linux_clflush(p);
44*fc8df113SFrançois Tigeot }
45*fc8df113SFrançois Tigeot 
46*fc8df113SFrançois Tigeot #endif	/* _ASM_SPECIAL_INSNS_H_ */
47