xref: /freebsd/sys/compat/linuxkpi/common/include/asm/topology.h (revision 3c9acc35b1d9e776fa10d45c0ad7d3737e8ccf38)
1*3c9acc35SJean-Sébastien Pédron /*-
2*3c9acc35SJean-Sébastien Pédron  * Copyright (c) 2025 The FreeBSD Foundation
3*3c9acc35SJean-Sébastien Pédron  * Copyright (c) 2025 Jean-Sébastien Pédron <dumbbell@FreeBSD.org>
4*3c9acc35SJean-Sébastien Pédron  *
5*3c9acc35SJean-Sébastien Pédron  * This software was developed by Jean-Sébastien Pédron under sponsorship
6*3c9acc35SJean-Sébastien Pédron  * from the FreeBSD Foundation.
7*3c9acc35SJean-Sébastien Pédron  *
8*3c9acc35SJean-Sébastien Pédron  * Redistribution and use in source and binary forms, with or without
9*3c9acc35SJean-Sébastien Pédron  * modification, are permitted provided that the following conditions
10*3c9acc35SJean-Sébastien Pédron  * are met:
11*3c9acc35SJean-Sébastien Pédron  * 1. Redistributions of source code must retain the above copyright
12*3c9acc35SJean-Sébastien Pédron  *    notice, this list of conditions and the following disclaimer.
13*3c9acc35SJean-Sébastien Pédron  * 2. Redistributions in binary form must reproduce the above copyright
14*3c9acc35SJean-Sébastien Pédron  *    notice, this list of conditions and the following disclaimer in the
15*3c9acc35SJean-Sébastien Pédron  *    documentation and/or other materials provided with the distribution.
16*3c9acc35SJean-Sébastien Pédron  *
17*3c9acc35SJean-Sébastien Pédron  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18*3c9acc35SJean-Sébastien Pédron  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19*3c9acc35SJean-Sébastien Pédron  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20*3c9acc35SJean-Sébastien Pédron  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21*3c9acc35SJean-Sébastien Pédron  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22*3c9acc35SJean-Sébastien Pédron  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23*3c9acc35SJean-Sébastien Pédron  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24*3c9acc35SJean-Sébastien Pédron  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25*3c9acc35SJean-Sébastien Pédron  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26*3c9acc35SJean-Sébastien Pédron  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27*3c9acc35SJean-Sébastien Pédron  * SUCH DAMAGE.
28*3c9acc35SJean-Sébastien Pédron  */
29*3c9acc35SJean-Sébastien Pédron 
30*3c9acc35SJean-Sébastien Pédron #ifndef	_LINUXKPI_ASM_TOPOLOGY_H_
31*3c9acc35SJean-Sébastien Pédron #define	_LINUXKPI_ASM_TOPOLOGY_H_
32*3c9acc35SJean-Sébastien Pédron 
33*3c9acc35SJean-Sébastien Pédron #if defined(__i386__) || defined(__amd64__)
34*3c9acc35SJean-Sébastien Pédron #include <sys/smp.h>
35*3c9acc35SJean-Sébastien Pédron 
36*3c9acc35SJean-Sébastien Pédron /*
37*3c9acc35SJean-Sébastien Pédron  * The following functions are defined in `arch/x86/include/asm/topology.h`
38*3c9acc35SJean-Sébastien Pédron  * and thus are specific to i386 and amd64.
39*3c9acc35SJean-Sébastien Pédron  */
40*3c9acc35SJean-Sébastien Pédron 
41*3c9acc35SJean-Sébastien Pédron static inline unsigned int
topology_num_cores_per_package(void)42*3c9acc35SJean-Sébastien Pédron topology_num_cores_per_package(void)
43*3c9acc35SJean-Sébastien Pédron {
44*3c9acc35SJean-Sébastien Pédron 	return (mp_ncores);
45*3c9acc35SJean-Sébastien Pédron }
46*3c9acc35SJean-Sébastien Pédron 
47*3c9acc35SJean-Sébastien Pédron static inline unsigned int
topology_num_threads_per_package(void)48*3c9acc35SJean-Sébastien Pédron topology_num_threads_per_package(void)
49*3c9acc35SJean-Sébastien Pédron {
50*3c9acc35SJean-Sébastien Pédron 	return (mp_ncpus);
51*3c9acc35SJean-Sébastien Pédron }
52*3c9acc35SJean-Sébastien Pédron #endif
53*3c9acc35SJean-Sébastien Pédron 
54*3c9acc35SJean-Sébastien Pédron #endif /* _LINUXKPI_ASM_TOPOLOGY_H_ */
55