5 #include <linux/cpumask.h>
6 #include <linux/init.h>
9 * We need the APIC definitions automatically as part of 'smp.h'
11 #ifdef CONFIG_X86_LOCAL_APIC
12 # include <asm/mpspec.h>
13 # include <asm/apic.h>
14 # ifdef CONFIG_X86_IO_APIC
15 # include <asm/io_apic.h>
19 extern cpumask_t cpu_callin_map;
21 extern void (*mtrr_hook) (void);
22 extern void zap_low_mappings (void);
24 extern u8 __initdata x86_cpu_to_apicid_init[];
25 extern void *x86_cpu_to_apicid_early_ptr;
27 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
28 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
29 DECLARE_PER_CPU(u8, cpu_llc_id);
30 DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
32 #ifdef CONFIG_HOTPLUG_CPU
33 extern void cpu_exit_clear(void);
34 extern void cpu_uninit(void);
35 extern void remove_siblinginfo(int cpu);
38 /* Globals due to paravirt */
39 extern void set_cpu_sibling_map(int cpu);
42 static inline void smp_prepare_boot_cpu(void)
44 smp_ops.smp_prepare_boot_cpu();
46 static inline void smp_prepare_cpus(unsigned int max_cpus)
48 smp_ops.smp_prepare_cpus(max_cpus);
50 static inline void smp_cpus_done(unsigned int max_cpus)
52 smp_ops.smp_cpus_done(max_cpus);
55 static inline void smp_send_stop(void)
57 smp_ops.smp_send_stop();
60 void native_smp_prepare_boot_cpu(void);
61 void native_smp_prepare_cpus(unsigned int max_cpus);
62 void native_smp_cpus_done(unsigned int max_cpus);
64 #ifndef CONFIG_PARAVIRT
65 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
68 extern int __cpu_disable(void);
69 extern void __cpu_die(unsigned int cpu);
72 * This function is needed by all SMP systems. It must _always_ be valid
73 * from the initial startup. We map APIC_BASE very early in page_setup(),
74 * so this is correct in the x86 case.
76 DECLARE_PER_CPU(int, cpu_number);
77 #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
79 #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
81 extern int safe_smp_processor_id(void);
83 void __cpuinit smp_store_cpu_info(int id);
85 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
86 static inline int num_booting_cpus(void)
88 return cpus_weight(cpu_callout_map);
91 #else /* CONFIG_SMP */
93 #define safe_smp_processor_id() 0
94 #define cpu_physical_id(cpu) boot_cpu_physical_apicid
96 #endif /* !CONFIG_SMP */
98 #ifdef CONFIG_X86_LOCAL_APIC
100 static __inline int logical_smp_processor_id(void)
102 /* we don't want to mark this access volatile - bad code generation */
103 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
106 # ifdef APIC_DEFINITION
107 extern int hard_smp_processor_id(void);
109 # include <mach_apicdef.h>
110 static inline int hard_smp_processor_id(void)
112 /* we don't want to mark this access volatile - bad code generation */
113 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
115 # endif /* APIC_DEFINITION */
117 #else /* CONFIG_X86_LOCAL_APIC */
120 # define hard_smp_processor_id() 0
123 #endif /* CONFIG_X86_LOCAL_APIC */
125 #endif /* !ASSEMBLY */