xref: /dflybsd-src/sys/dev/drm/include/linux/smp.h (revision 111dab5b72b72339c1e73c46f14879e6fc06331d)
1*111dab5bSFrançois Tigeot /*
2*111dab5bSFrançois Tigeot  * Copyright (c) 2019 François Tigeot <ftigeot@wolfpond.org>
3*111dab5bSFrançois Tigeot  * All rights reserved.
4*111dab5bSFrançois Tigeot  *
5*111dab5bSFrançois Tigeot  * Redistribution and use in source and binary forms, with or without
6*111dab5bSFrançois Tigeot  * modification, are permitted provided that the following conditions
7*111dab5bSFrançois Tigeot  * are met:
8*111dab5bSFrançois Tigeot  * 1. Redistributions of source code must retain the above copyright
9*111dab5bSFrançois Tigeot  *    notice unmodified, this list of conditions, and the following
10*111dab5bSFrançois Tigeot  *    disclaimer.
11*111dab5bSFrançois Tigeot  * 2. Redistributions in binary form must reproduce the above copyright
12*111dab5bSFrançois Tigeot  *    notice, this list of conditions and the following disclaimer in the
13*111dab5bSFrançois Tigeot  *    documentation and/or other materials provided with the distribution.
14*111dab5bSFrançois Tigeot  *
15*111dab5bSFrançois Tigeot  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16*111dab5bSFrançois Tigeot  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17*111dab5bSFrançois Tigeot  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18*111dab5bSFrançois Tigeot  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19*111dab5bSFrançois Tigeot  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20*111dab5bSFrançois Tigeot  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21*111dab5bSFrançois Tigeot  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22*111dab5bSFrançois Tigeot  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23*111dab5bSFrançois Tigeot  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24*111dab5bSFrançois Tigeot  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25*111dab5bSFrançois Tigeot  */
26*111dab5bSFrançois Tigeot 
27*111dab5bSFrançois Tigeot #ifndef _LINUX_SMP_H_
28*111dab5bSFrançois Tigeot #define _LINUX_SMP_H_
29*111dab5bSFrançois Tigeot 
30*111dab5bSFrançois Tigeot #include <linux/errno.h>
31*111dab5bSFrançois Tigeot #include <linux/types.h>
32*111dab5bSFrançois Tigeot #include <linux/list.h>
33*111dab5bSFrançois Tigeot #include <linux/cpumask.h>
34*111dab5bSFrançois Tigeot #include <linux/init.h>
35*111dab5bSFrançois Tigeot 
36*111dab5bSFrançois Tigeot #include <linux/preempt.h>
37*111dab5bSFrançois Tigeot 
38*111dab5bSFrançois Tigeot static inline uint32_t smp_processor_id(void)
39*111dab5bSFrançois Tigeot {
40*111dab5bSFrançois Tigeot 	return mycpuid;
41*111dab5bSFrançois Tigeot }
42*111dab5bSFrançois Tigeot 
43*111dab5bSFrançois Tigeot static inline uint32_t get_cpu(void)
44*111dab5bSFrançois Tigeot {
45*111dab5bSFrançois Tigeot 	preempt_disable();
46*111dab5bSFrançois Tigeot 
47*111dab5bSFrançois Tigeot 	/* Regular DragonFly kernel threads always run on the same CPU */
48*111dab5bSFrançois Tigeot 	return 0;
49*111dab5bSFrançois Tigeot }
50*111dab5bSFrançois Tigeot 
51*111dab5bSFrançois Tigeot #define put_cpu()	preempt_enable()
52*111dab5bSFrançois Tigeot 
53*111dab5bSFrançois Tigeot #endif	/* _LINUX_SMP_H_ */
54