xref: /freebsd/sys/x86/include/x86_smp.h (revision 52f72944b8f5abb2386eae924357dee8aea17d5b)
1 /*-
2  * SPDX-License-Identifier: Beerware
3  *
4  * ----------------------------------------------------------------------------
5  * "THE BEER-WARE LICENSE" (Revision 42):
6  * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
7  * can do whatever you want with this stuff. If we meet some day, and you think
8  * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
9  * ----------------------------------------------------------------------------
10  *
11  * $FreeBSD$
12  *
13  */
14 
15 #ifndef _X86_X86_SMP_H_
16 #define	_X86_X86_SMP_H_
17 
18 #include <sys/bus.h>
19 #include <machine/frame.h>
20 #include <machine/intr_machdep.h>
21 #include <x86/apicvar.h>
22 #include <machine/pcb.h>
23 
24 struct pmap;
25 
26 /* global data in mp_x86.c */
27 extern int mp_naps;
28 extern int boot_cpu_id;
29 extern struct pcb stoppcbs[];
30 extern int cpu_apic_ids[];
31 extern int bootAP;
32 extern void *dpcpu;
33 extern char *bootSTK;
34 extern void *bootstacks[];
35 extern volatile u_int cpu_ipi_pending[];
36 extern volatile int aps_ready;
37 extern struct mtx ap_boot_mtx;
38 extern int cpu_logical;
39 extern int cpu_cores;
40 extern volatile uint32_t smp_tlb_generation;
41 extern struct pmap *smp_tlb_pmap;
42 extern vm_offset_t smp_tlb_addr1, smp_tlb_addr2;
43 extern u_int xhits_gbl[];
44 extern u_int xhits_pg[];
45 extern u_int xhits_rng[];
46 extern u_int ipi_global;
47 extern u_int ipi_page;
48 extern u_int ipi_range;
49 extern u_int ipi_range_size;
50 
51 extern int nmi_kdb_lock;
52 extern int nmi_is_broadcast;
53 
54 struct cpu_info {
55 	int	cpu_present:1;
56 	int	cpu_bsp:1;
57 	int	cpu_disabled:1;
58 	int	cpu_hyperthread:1;
59 };
60 extern struct cpu_info *cpu_info;
61 
62 #ifdef COUNT_IPIS
63 extern u_long *ipi_invltlb_counts[MAXCPU];
64 extern u_long *ipi_invlrng_counts[MAXCPU];
65 extern u_long *ipi_invlpg_counts[MAXCPU];
66 extern u_long *ipi_invlcache_counts[MAXCPU];
67 extern u_long *ipi_rendezvous_counts[MAXCPU];
68 #endif
69 
70 /* IPI handlers */
71 inthand_t
72 	IDTVEC(invltlb),	/* TLB shootdowns - global */
73 	IDTVEC(invlpg),		/* TLB shootdowns - 1 page */
74 	IDTVEC(invlrng),	/* TLB shootdowns - page range */
75 	IDTVEC(invlcache),	/* Write back and invalidate cache */
76 	IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */
77 	IDTVEC(cpustop),	/* CPU stops & waits to be restarted */
78 	IDTVEC(cpususpend),	/* CPU suspends & waits to be resumed */
79 	IDTVEC(rendezvous);	/* handle CPU rendezvous */
80 
81 /* functions in x86_mp.c */
82 void	assign_cpu_ids(void);
83 void	cpu_add(u_int apic_id, char boot_cpu);
84 void	cpustop_handler(void);
85 void	cpususpend_handler(void);
86 void	init_secondary_tail(void);
87 void	invltlb_handler(void);
88 void	invlpg_handler(void);
89 void	invlrng_handler(void);
90 void	invlcache_handler(void);
91 void	init_secondary(void);
92 void	ipi_startup(int apic_id, int vector);
93 void	ipi_all_but_self(u_int ipi);
94 void 	ipi_bitmap_handler(struct trapframe frame);
95 void	ipi_cpu(int cpu, u_int ipi);
96 int	ipi_nmi_handler(void);
97 void	ipi_selected(cpuset_t cpus, u_int ipi);
98 u_int	mp_bootaddress(u_int);
99 void	set_interrupt_apic_ids(void);
100 void	smp_cache_flush(void);
101 void	smp_masked_invlpg(cpuset_t mask, vm_offset_t addr, struct pmap *pmap);
102 void	smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva,
103 	    vm_offset_t endva, struct pmap *pmap);
104 void	smp_masked_invltlb(cpuset_t mask, struct pmap *pmap);
105 void	mem_range_AP_init(void);
106 void	topo_probe(void);
107 void	ipi_send_cpu(int cpu, u_int ipi);
108 
109 #endif
110