xref: /freebsd/sys/compat/linuxkpi/common/include/asm/smp.h (revision 95ee2897e98f5d444f26ed2334cc7c439f9c16c6)
1c12488bbSMark Johnston /*-
2c12488bbSMark Johnston  * Copyright (c) 2017 Mark Johnston <markj@FreeBSD.org>
3c12488bbSMark Johnston  *
4c12488bbSMark Johnston  * Redistribution and use in source and binary forms, with or without
5c12488bbSMark Johnston  * modification, are permitted provided that the following conditions are
6c12488bbSMark Johnston  * met:
7c12488bbSMark Johnston  * 1. Redistributions of source code must retain the above copyright
8c12488bbSMark Johnston  *    notice, this list of conditions and the following disclaimer.
9c12488bbSMark Johnston  * 2. Redistributions in binary form must reproduce the above copyright
10c12488bbSMark Johnston  *    notice, this list of conditions and the following disclaimer in
11c12488bbSMark Johnston  *    the documentation and/or other materials provided with the
12c12488bbSMark Johnston  *    distribution.
13c12488bbSMark Johnston  *
14c12488bbSMark Johnston  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15c12488bbSMark Johnston  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16c12488bbSMark Johnston  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17c12488bbSMark Johnston  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18c12488bbSMark Johnston  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19c12488bbSMark Johnston  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20c12488bbSMark Johnston  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21c12488bbSMark Johnston  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22c12488bbSMark Johnston  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23c12488bbSMark Johnston  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24c12488bbSMark Johnston  * SUCH DAMAGE.
25c12488bbSMark Johnston  */
26c12488bbSMark Johnston 
27307f78f3SVladimir Kondratyev #ifndef _LINUXKPI_ASM_SMP_H_
28307f78f3SVladimir Kondratyev #define	_LINUXKPI_ASM_SMP_H_
29c12488bbSMark Johnston 
30*11aaefc9SJean-Sébastien Pédron #include <linux/jump_label.h>
31*11aaefc9SJean-Sébastien Pédron #include <linux/preempt.h>
32*11aaefc9SJean-Sébastien Pédron #include <asm/fpu/api.h>
33*11aaefc9SJean-Sébastien Pédron 
34c12488bbSMark Johnston #if defined(__i386__) || defined(__amd64__)
35c12488bbSMark Johnston 
36c12488bbSMark Johnston #define	wbinvd_on_all_cpus()	linux_wbinvd_on_all_cpus()
37c12488bbSMark Johnston 
38c12488bbSMark Johnston int	linux_wbinvd_on_all_cpus(void);
39c12488bbSMark Johnston 
40c12488bbSMark Johnston #endif
41c12488bbSMark Johnston 
42d6c83356SMark Johnston #define	get_cpu() ({			\
43e4ba1a50SMark Johnston 	critical_enter();		\
44d6c83356SMark Johnston 	PCPU_GET(cpuid);		\
45d6c83356SMark Johnston })
46d6c83356SMark Johnston 
47d6c83356SMark Johnston #define	put_cpu()			\
48e4ba1a50SMark Johnston 	critical_exit()
49d6c83356SMark Johnston 
50307f78f3SVladimir Kondratyev #endif /* _LINUXKPI_ASM_SMP_H_ */
51