xref: /freebsd/sys/amd64/include/smp.h (revision 895f86f15fbf6540071feb9328c3c50ed1f027b8)
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 
13 #ifndef _MACHINE_SMP_H_
14 #define _MACHINE_SMP_H_
15 
16 #ifdef _KERNEL
17 
18 #ifdef SMP
19 
20 #ifndef LOCORE
21 
22 #include <sys/bus.h>
23 #include <machine/frame.h>
24 #include <machine/intr_machdep.h>
25 #include <x86/apicvar.h>
26 #include <machine/pcb.h>
27 
28 struct pmap;
29 
30 /* global symbols in mpboot.S */
31 extern char			mptramp_start[];
32 extern char			mptramp_end[];
33 extern u_int32_t		mptramp_pagetables;
34 
35 /* global data in mp_machdep.c */
36 extern int			mp_naps;
37 extern int			boot_cpu_id;
38 extern struct pcb		stoppcbs[];
39 extern int			cpu_apic_ids[];
40 extern void *dpcpu;
41 extern char *bootSTK;
42 extern int bootAP;
43 extern void *bootstacks[];
44 extern volatile u_int cpu_ipi_pending[];
45 extern volatile int aps_ready;
46 extern struct mtx ap_boot_mtx;
47 extern int cpu_logical;
48 extern int cpu_cores;
49 extern int pmap_pcid_enabled;
50 extern int invpcid_works;
51 extern u_int xhits_gbl[];
52 extern u_int xhits_pg[];
53 extern u_int xhits_rng[];
54 extern u_int ipi_global;
55 extern u_int ipi_page;
56 extern u_int ipi_range;
57 extern u_int ipi_range_size;
58 extern struct pmap *smp_tlb_pmap;
59 
60 extern volatile int smp_tlb_wait;
61 
62 struct cpu_info {
63 	int	cpu_present:1;
64 	int	cpu_bsp:1;
65 	int	cpu_disabled:1;
66 	int	cpu_hyperthread:1;
67 };
68 extern struct cpu_info cpu_info[];
69 
70 #ifdef COUNT_IPIS
71 extern u_long *ipi_invltlb_counts[MAXCPU];
72 extern u_long *ipi_invlrng_counts[MAXCPU];
73 extern u_long *ipi_invlpg_counts[MAXCPU];
74 extern u_long *ipi_invlcache_counts[MAXCPU];
75 extern u_long *ipi_rendezvous_counts[MAXCPU];
76 #endif
77 
78 /* IPI handlers */
79 inthand_t
80 	IDTVEC(invltlb),	/* TLB shootdowns - global */
81 	IDTVEC(invltlb_pcid),	/* TLB shootdowns - global, pcid */
82 	IDTVEC(invltlb_invpcid),/* TLB shootdowns - global, invpcid */
83 	IDTVEC(invlpg),		/* TLB shootdowns - 1 page */
84 	IDTVEC(invlrng),	/* TLB shootdowns - page range */
85 	IDTVEC(invlcache),	/* Write back and invalidate cache */
86 	IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */
87 	IDTVEC(cpustop),	/* CPU stops & waits to be restarted */
88 	IDTVEC(cpususpend),	/* CPU suspends & waits to be resumed */
89 	IDTVEC(justreturn),	/* interrupt CPU with minimum overhead */
90 	IDTVEC(rendezvous);	/* handle CPU rendezvous */
91 
92 /* functions in mp_machdep.c */
93 void	assign_cpu_ids(void);
94 void	cpu_add(u_int apic_id, char boot_cpu);
95 void	cpustop_handler(void);
96 void	cpususpend_handler(void);
97 void	init_secondary_tail(void);
98 void	invltlb_handler(void);
99 void	invltlb_pcid_handler(void);
100 void	invltlb_invpcid_handler(void);
101 void	invlpg_handler(void);
102 void	invlrng_handler(void);
103 void	invlcache_handler(void);
104 void	init_secondary(void);
105 void	ipi_startup(int apic_id, int vector);
106 void	ipi_all_but_self(u_int ipi);
107 void 	ipi_bitmap_handler(struct trapframe frame);
108 void	ipi_cpu(int cpu, u_int ipi);
109 int	ipi_nmi_handler(void);
110 void	ipi_selected(cpuset_t cpus, u_int ipi);
111 u_int	mp_bootaddress(u_int);
112 void	set_interrupt_apic_ids(void);
113 void	smp_cache_flush(void);
114 void	smp_masked_invlpg(cpuset_t mask, vm_offset_t addr);
115 void	smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva,
116 	    vm_offset_t endva);
117 void	smp_masked_invltlb(cpuset_t mask, struct pmap *pmap);
118 int	native_start_all_aps(void);
119 void	mem_range_AP_init(void);
120 void	topo_probe(void);
121 void	ipi_send_cpu(int cpu, u_int ipi);
122 
123 #endif /* !LOCORE */
124 #endif /* SMP */
125 
126 #endif /* _KERNEL */
127 #endif /* _MACHINE_SMP_H_ */
128