Move common code from sys/i386/i386/mp_machdep.c and

sys/amd64/amd64/mp_machdep.c, to the new common x86 source
sys/x86/x86/mp_x86.c.

Proposed and reviewed by:	jhb
Review:	https://reviews.freebsd.org/D2347
Sponsored by:	The FreeBSD Foundation
This commit is contained in:
Konstantin Belousov 2015-04-24 16:20:56 +00:00
parent 04c5335197
commit 02c26f81a7
9 changed files with 1231 additions and 2040 deletions

File diff suppressed because it is too large Load Diff

View File

@ -35,6 +35,39 @@ extern int mp_naps;
extern int boot_cpu_id;
extern struct pcb stoppcbs[];
extern int cpu_apic_ids[];
extern int bootAP;
extern void *dpcpu;
extern char *bootSTK;
extern int bootAP;
extern void *bootstacks[];
extern volatile u_int cpu_ipi_pending[];
extern volatile int aps_ready;
extern struct mtx ap_boot_mtx;
extern int cpu_logical;
extern int cpu_cores;
extern int pmap_pcid_enabled;
extern u_int xhits_gbl[];
extern u_int xhits_pg[];
extern u_int xhits_rng[];
extern u_int ipi_global;
extern u_int ipi_page;
extern u_int ipi_range;
extern u_int ipi_range_size;
extern u_int ipi_masked_global;
extern u_int ipi_masked_page;
extern u_int ipi_masked_range;
extern u_int ipi_masked_range_size;
extern volatile int smp_tlb_wait;
struct cpu_info {
int cpu_present:1;
int cpu_bsp:1;
int cpu_disabled:1;
int cpu_hyperthread:1;
};
extern struct cpu_info cpu_info[];
#ifdef COUNT_IPIS
extern u_long *ipi_invltlb_counts[MAXCPU];
extern u_long *ipi_invlrng_counts[MAXCPU];
@ -60,9 +93,11 @@ inthand_t
struct pmap;
/* functions in mp_machdep.c */
void assign_cpu_ids(void);
void cpu_add(u_int apic_id, char boot_cpu);
void cpustop_handler(void);
void cpususpend_handler(void);
void init_secondary_tail(void);
void invltlb_handler(void);
void invltlb_pcid_handler(void);
void invlpg_handler(void);
@ -77,6 +112,7 @@ void ipi_cpu(int cpu, u_int ipi);
int ipi_nmi_handler(void);
void ipi_selected(cpuset_t cpus, u_int ipi);
u_int mp_bootaddress(u_int);
void set_interrupt_apic_ids(void);
void smp_cache_flush(void);
void smp_invlpg(struct pmap *pmap, vm_offset_t addr);
void smp_masked_invlpg(cpuset_t mask, struct pmap *pmap, vm_offset_t addr);
@ -87,6 +123,9 @@ void smp_masked_invlpg_range(cpuset_t mask, struct pmap *pmap,
void smp_invltlb(struct pmap *pmap);
void smp_masked_invltlb(cpuset_t mask, struct pmap *pmap);
int native_start_all_aps(void);
void mem_range_AP_init(void);
void topo_probe(void);
void ipi_send_cpu(int cpu, u_int ipi);
#endif /* !LOCORE */
#endif /* SMP */

View File

@ -569,6 +569,7 @@ x86/x86/local_apic.c standard
x86/x86/mca.c standard
x86/x86/mptable.c optional mptable
x86/x86/mptable_pci.c optional mptable pci
x86/x86/mp_x86.c optional smp
x86/x86/msi.c optional pci
x86/x86/nexus.c standard
x86/x86/pvclock.c standard

View File

@ -587,6 +587,7 @@ x86/x86/local_apic.c optional apic
x86/x86/mca.c standard
x86/x86/mptable.c optional apic native
x86/x86/mptable_pci.c optional apic native pci
x86/x86/mp_x86.c optional native smp
x86/x86/msi.c optional apic pci
x86/x86/nexus.c standard
x86/x86/tsc.c standard

View File

@ -256,6 +256,7 @@ x86/x86/io_apic.c optional apic
x86/x86/legacy.c standard
x86/x86/local_apic.c optional apic
x86/x86/mca.c standard
x86/x86/mp_x86.c optional smp
x86/x86/mptable.c optional apic
x86/x86/mptable_pci.c optional apic pci
x86/x86/msi.c optional apic pci

File diff suppressed because it is too large Load Diff

View File

@ -36,6 +36,37 @@ extern int mp_naps;
extern int boot_cpu_id;
extern struct pcb stoppcbs[];
extern int cpu_apic_ids[];
extern int bootAP;
extern void *dpcpu;
extern char *bootSTK;
extern int bootAP;
extern void *bootstacks[];
extern volatile u_int cpu_ipi_pending[];
extern volatile int aps_ready;
extern struct mtx ap_boot_mtx;
extern int cpu_logical;
extern int cpu_cores;
extern volatile int smp_tlb_wait;
extern u_int xhits_gbl[];
extern u_int xhits_pg[];
extern u_int xhits_rng[];
extern u_int ipi_global;
extern u_int ipi_page;
extern u_int ipi_range;
extern u_int ipi_range_size;
extern u_int ipi_masked_global;
extern u_int ipi_masked_page;
extern u_int ipi_masked_range;
extern u_int ipi_masked_range_size;
struct cpu_info {
int cpu_present:1;
int cpu_bsp:1;
int cpu_disabled:1;
int cpu_hyperthread:1;
};
extern struct cpu_info cpu_info[];
#ifdef COUNT_IPIS
extern u_long *ipi_invltlb_counts[MAXCPU];
extern u_long *ipi_invlrng_counts[MAXCPU];
@ -56,11 +87,13 @@ inthand_t
IDTVEC(rendezvous); /* handle CPU rendezvous */
/* functions in mp_machdep.c */
void assign_cpu_ids(void);
void cpu_add(u_int apic_id, char boot_cpu);
void cpustop_handler(void);
#ifndef XEN
void cpususpend_handler(void);
#endif
void init_secondary_tail(void);
void invltlb_handler(void);
void invlpg_handler(void);
void invlrng_handler(void);
@ -75,6 +108,7 @@ void ipi_cpu(int cpu, u_int ipi);
int ipi_nmi_handler(void);
void ipi_selected(cpuset_t cpus, u_int ipi);
u_int mp_bootaddress(u_int);
void set_interrupt_apic_ids(void);
void smp_cache_flush(void);
void smp_invlpg(vm_offset_t addr);
void smp_masked_invlpg(cpuset_t mask, vm_offset_t addr);
@ -83,6 +117,9 @@ void smp_masked_invlpg_range(cpuset_t mask, vm_offset_t startva,
vm_offset_t endva);
void smp_invltlb(void);
void smp_masked_invltlb(cpuset_t mask);
void mem_range_AP_init(void);
void topo_probe(void);
void ipi_send_cpu(int cpu, u_int ipi);
#ifdef XEN
void ipi_to_irq_init(void);

View File

@ -100,8 +100,6 @@ extern void failsafe_callback(void);
/*--------------------------- Forward Declarations ---------------------------*/
static driver_filter_t smp_reschedule_interrupt;
static driver_filter_t smp_call_function_interrupt;
static void assign_cpu_ids(void);
static void set_interrupt_apic_ids(void);
static int start_all_aps(void);
static int start_ap(int apic_id);
static void release_aps(void *dummy);
@ -112,12 +110,6 @@ static void release_aps(void *dummy);
/*-------------------------------- Local Types -------------------------------*/
typedef void call_data_func_t(uintptr_t , uintptr_t);
struct cpu_info {
int cpu_present:1;
int cpu_bsp:1;
int cpu_disabled:1;
};
struct xen_ipi_handler
{
driver_filter_t *filter;
@ -136,7 +128,7 @@ static cpuset_t hyperthreading_cpus_mask;
int mp_naps; /* # of Applications processors */
int boot_cpu_id = -1; /* designated BSP */
static int bootAP;
int bootAP;
static union descriptor *bootAPgdt;
/* Free these after use */
@ -153,24 +145,24 @@ static u_int logical_cpus;
static volatile cpuset_t ipi_nmi_pending;
/* used to hold the AP's until we are ready to release them */
static struct mtx ap_boot_mtx;
struct mtx ap_boot_mtx;
/* Set to 1 once we're ready to let the APs out of the pen. */
static volatile int aps_ready = 0;
volatile int aps_ready = 0;
/*
* Store data from cpu_add() until later in the boot when we actually setup
* the APs.
*/
static struct cpu_info cpu_info[MAX_APIC_ID + 1];
struct cpu_info cpu_info[MAX_APIC_ID + 1];
int cpu_apic_ids[MAXCPU];
int apic_cpuids[MAX_APIC_ID + 1];
/* Holds pending bitmap based IPIs per CPU */
static volatile u_int cpu_ipi_pending[MAXCPU];
volatile u_int cpu_ipi_pending[MAXCPU];
static int cpu_logical;
static int cpu_cores;
int cpu_logical;
int cpu_cores;
static const struct xen_ipi_handler xen_ipis[] =
{
@ -668,7 +660,7 @@ init_secondary(void)
* We also do not tell it about the BSP since it tells itself about
* the BSP internally to work with UP kernels and on UP machines.
*/
static void
void
set_interrupt_apic_ids(void)
{
u_int i, apic_id;
@ -694,7 +686,7 @@ set_interrupt_apic_ids(void)
/*
* Assign logical CPU IDs to local APICs.
*/
static void
void
assign_cpu_ids(void)
{
u_int i;
@ -986,7 +978,7 @@ ipi_pcpu(int cpu, u_int ipi)
/*
* send an IPI to a specific CPU.
*/
static void
void
ipi_send_cpu(int cpu, u_int ipi)
{
u_int bitmap, old_pending, new_pending;

1120
sys/x86/x86/mp_x86.c Normal file

File diff suppressed because it is too large Load Diff