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