]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sys/smp.h
Give more correct params to busdma_*
[FreeBSD/FreeBSD.git] / sys / sys / smp.h
1 /*
2  * ----------------------------------------------------------------------------
3  * "THE BEER-WARE LICENSE" (Revision 42):
4  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
5  * can do whatever you want with this stuff. If we meet some day, and you think
6  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
7  * ----------------------------------------------------------------------------
8  *
9  * $FreeBSD$
10  */
11
12 #ifndef _SYS_SMP_H_
13 #define _SYS_SMP_H_
14
15 #ifdef _KERNEL
16
17 #ifndef LOCORE
18
19 #ifdef SMP
20
21 /*
22  * Topology of a NUMA or HTT system.
23  *
24  * The top level topology is an array of pointers to groups.  Each group
25  * contains a bitmask of cpus in its group or subgroups.  It may also
26  * contain a pointer to an array of child groups.
27  *
28  * The bitmasks at non leaf groups may be used by consumers who support
29  * a smaller depth than the hardware provides.
30  *
31  * The topology may be omitted by systems where all CPUs are equal.
32  */
33
34 struct cpu_group {
35         u_int   cg_mask;                /* Mask of cpus in this group. */
36         int     cg_count;               /* Count of cpus in this group. */
37         int     cg_children;            /* Number of children groups. */
38         struct cpu_group *cg_child;     /* Optional child group. */
39 };
40
41 struct cpu_top {
42         int     ct_count;               /* Count of groups. */
43         struct cpu_group *ct_group;     /* Array of pointers to cpu groups. */
44 };
45
46 extern struct cpu_top *smp_topology;
47 extern void (*cpustop_restartfunc)(void);
48 extern int mp_ncpus;
49 extern int smp_active;
50 extern volatile int smp_started;
51 extern int smp_cpus;
52 extern u_int all_cpus;
53 extern volatile u_int started_cpus;
54 extern volatile u_int stopped_cpus;
55 extern u_int mp_maxid;
56
57 /*
58  * Macro allowing us to determine whether a CPU is absent at any given
59  * time, thus permitting us to configure sparse maps of cpuid-dependent
60  * (per-CPU) structures.
61  */
62 #define CPU_ABSENT(x_cpu)       ((all_cpus & (1 << (x_cpu))) == 0)
63
64 /*
65  * Machine dependent functions used to initialize MP support.
66  *
67  * The cpu_mp_probe() should check to see if MP support is present and return
68  * zero if it is not or non-zero if it is.  If MP support is present, then
69  * cpu_mp_start() will be called so that MP can be enabled.  This function
70  * should do things such as startup secondary processors.  It should also
71  * setup mp_ncpus, all_cpus, and smp_cpus.  It should also ensure that
72  * smp_active and smp_started are initialized at the appropriate time.
73  * Once cpu_mp_start() returns, machine independent MP startup code will be
74  * executed and a simple message will be output to the console.  Finally,
75  * cpu_mp_announce() will be called so that machine dependent messages about
76  * the MP support may be output to the console if desired.
77  */
78 struct thread;
79
80 void    cpu_mp_announce(void);
81 int     cpu_mp_probe(void);
82 void    cpu_mp_start(void);
83
84 void    forward_signal(struct thread *);
85 void    forward_roundrobin(void);
86 int     restart_cpus(u_int);
87 int     stop_cpus(u_int);
88 void    smp_rendezvous_action(void);
89 void    smp_rendezvous(void (*)(void *), 
90                        void (*)(void *),
91                        void (*)(void *),
92                        void *arg);
93 #else /* SMP */
94 #define CPU_ABSENT(x_cpu)       (0)
95 #endif /* SMP */
96 #endif /* !LOCORE */
97 #endif /* _KERNEL */
98 #endif /* _SYS_SMP_H_ */