smp.h revision 281940
1139823Simp/*-
25191Swollman * ----------------------------------------------------------------------------
35191Swollman * "THE BEER-WARE LICENSE" (Revision 42):
45191Swollman * <phk@FreeBSD.org> wrote this file.  As long as you retain this notice you
55191Swollman * can do whatever you want with this stuff. If we meet some day, and you think
65191Swollman * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
75191Swollman * ----------------------------------------------------------------------------
85191Swollman *
95191Swollman * $FreeBSD: head/sys/i386/include/smp.h 281940 2015-04-24 16:20:56Z kib $
105191Swollman *
115191Swollman */
125191Swollman
135191Swollman#ifndef _MACHINE_SMP_H_
145191Swollman#define _MACHINE_SMP_H_
155191Swollman
165191Swollman#ifdef _KERNEL
175191Swollman
185191Swollman#ifdef SMP
195191Swollman
205191Swollman#ifndef LOCORE
215191Swollman
225191Swollman#include <sys/bus.h>
235191Swollman#include <machine/frame.h>
245191Swollman#include <machine/intr_machdep.h>
255191Swollman#include <x86/apicvar.h>
265191Swollman#include <machine/pcb.h>
275191Swollman
285191Swollman/* global data in mpboot.s */
295191Swollmanextern int			bootMP_size;
3050477Speter
315191Swollman/* functions in mpboot.s */
325191Swollmanvoid	bootMP(void);
335191Swollman
345191Swollman/* global data in mp_machdep.c */
355191Swollmanextern int			mp_naps;
365191Swollmanextern int			boot_cpu_id;
375191Swollmanextern struct pcb		stoppcbs[];
385191Swollmanextern int			cpu_apic_ids[];
395191Swollmanextern int bootAP;
405191Swollmanextern void *dpcpu;
4197290Sbrooksextern char *bootSTK;
4271862Speterextern int bootAP;
435191Swollmanextern void *bootstacks[];
445191Swollmanextern volatile u_int cpu_ipi_pending[];
4524204Sbdeextern volatile int aps_ready;
465191Swollmanextern struct mtx ap_boot_mtx;
475191Swollmanextern int cpu_logical;
48130933Sbrooksextern int cpu_cores;
495191Swollmanextern volatile int smp_tlb_wait;
505191Swollmanextern u_int xhits_gbl[];
515191Swollmanextern u_int xhits_pg[];
525191Swollmanextern u_int xhits_rng[];
5332350Seivindextern u_int ipi_global;
5454263Sshinextern u_int ipi_page;
555191Swollmanextern u_int ipi_range;
565191Swollmanextern u_int ipi_range_size;
575191Swollmanextern u_int ipi_masked_global;
585191Swollmanextern u_int ipi_masked_page;
595191Swollmanextern u_int ipi_masked_range;
605191Swollmanextern u_int ipi_masked_range_size;
615191Swollman
6297290Sbrooksstruct cpu_info {
6310429Sbde	int	cpu_present:1;
6497290Sbrooks	int	cpu_bsp:1;
65147256Sbrooks	int	cpu_disabled:1;
6697290Sbrooks	int	cpu_hyperthread:1;
675191Swollman};
6897290Sbrooksextern struct cpu_info cpu_info[];
6997290Sbrooks
7097290Sbrooks#ifdef COUNT_IPIS
7197290Sbrooksextern u_long *ipi_invltlb_counts[MAXCPU];
72160195Ssamextern u_long *ipi_invlrng_counts[MAXCPU];
7397290Sbrooksextern u_long *ipi_invlpg_counts[MAXCPU];
7497290Sbrooksextern u_long *ipi_invlcache_counts[MAXCPU];
7597290Sbrooksextern u_long *ipi_rendezvous_counts[MAXCPU];
7697290Sbrooks#endif
77130933Sbrooks
78130933Sbrooks/* IPI handlers */
7997290Sbrooksinthand_t
80160195Ssam	IDTVEC(invltlb),	/* TLB shootdowns - global */
815191Swollman	IDTVEC(invlpg),		/* TLB shootdowns - 1 page */
8297290Sbrooks	IDTVEC(invlrng),	/* TLB shootdowns - page range */
8397290Sbrooks	IDTVEC(invlcache),	/* Write back and invalidate cache */
845191Swollman	IDTVEC(ipi_intr_bitmap_handler), /* Bitmap based IPIs */
85131670Sbms	IDTVEC(cpustop),	/* CPU stops & waits to be restarted */
86147256Sbrooks	IDTVEC(cpususpend),	/* CPU suspends & waits to be resumed */
87147256Sbrooks	IDTVEC(rendezvous);	/* handle CPU rendezvous */
88147256Sbrooks
89147256Sbrooks/* functions in mp_machdep.c */
90147256Sbrooksvoid	assign_cpu_ids(void);
9197290Sbrooksvoid	cpu_add(u_int apic_id, char boot_cpu);
9297290Sbrooksvoid	cpustop_handler(void);
93121816Sbrooks#ifndef XEN
945191Swollmanvoid	cpususpend_handler(void);
955191Swollman#endif
96152308Sglebiusvoid	init_secondary_tail(void);
9741757Seivindvoid	invltlb_handler(void);
9841757Seivindvoid	invlpg_handler(void);
995191Swollmanvoid	invlrng_handler(void);
1005191Swollmanvoid	invlcache_handler(void);
10153115Sphkvoid	init_secondary(void);
1025191Swollmanvoid	ipi_startup(int apic_id, int vector);
103147611Sdwmalonevoid	ipi_all_but_self(u_int ipi);
10497290Sbrooks#ifndef XEN
10597290Sbrooksvoid 	ipi_bitmap_handler(struct trapframe frame);
1065191Swollman#endif
1075191Swollmanvoid	ipi_cpu(int cpu, u_int ipi);
10897290Sbrooksint	ipi_nmi_handler(void);
10997290Sbrooksvoid	ipi_selected(cpuset_t cpus, u_int ipi);
11097290Sbrooksu_int	mp_bootaddress(u_int);
11197290Sbrooksvoid	set_interrupt_apic_ids(void);
11297290Sbrooksvoid	smp_cache_flush(void);
11397290Sbrooksvoid	smp_invlpg(vm_offset_t addr);
11497290Sbrooksvoid	smp_masked_invlpg(cpuset_t mask, vm_offset_t addr);
115151266Sthompsavoid	smp_invlpg_range(vm_offset_t startva, vm_offset_t endva);
116151266Sthompsavoid	smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva,
117151266Sthompsa	    vm_offset_t endva);
118151266Sthompsavoid	smp_invltlb(void);
119151266Sthompsavoid	smp_masked_invltlb(cpuset_t mask);
12097290Sbrooksvoid	mem_range_AP_init(void);
12197290Sbrooksvoid	topo_probe(void);
1225191Swollmanvoid	ipi_send_cpu(int cpu, u_int ipi);
123131669Sbms
124126777Srwatson#ifdef XEN
125126777Srwatsonvoid ipi_to_irq_init(void);
126131669Sbms#endif
127131669Sbms#endif /* !LOCORE */
12897290Sbrooks#endif /* SMP */
129131669Sbms
130131669Sbms#endif /* _KERNEL */
13197290Sbrooks#endif /* _MACHINE_SMP_H_ */
13297290Sbrooks