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 u16 __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(u16, cpu_llc_id);
30 DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
33 #ifndef CONFIG_PARAVIRT
34 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
37 extern int __cpu_disable(void);
38 extern void __cpu_die(unsigned int cpu);
41 * This function is needed by all SMP systems. It must _always_ be valid
42 * from the initial startup. We map APIC_BASE very early in page_setup(),
43 * so this is correct in the x86 case.
45 DECLARE_PER_CPU(int, cpu_number);
46 #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
48 #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
50 extern int safe_smp_processor_id(void);
52 void __cpuinit smp_store_cpu_info(int id);
54 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
55 static inline int num_booting_cpus(void)
57 return cpus_weight(cpu_callout_map);
60 #else /* CONFIG_SMP */
62 #define safe_smp_processor_id() 0
63 #define cpu_physical_id(cpu) boot_cpu_physical_apicid
65 #endif /* !CONFIG_SMP */
67 #ifdef CONFIG_X86_LOCAL_APIC
69 static __inline int logical_smp_processor_id(void)
71 /* we don't want to mark this access volatile - bad code generation */
72 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
75 # ifdef APIC_DEFINITION
76 extern int hard_smp_processor_id(void);
78 # include <mach_apicdef.h>
79 static inline int hard_smp_processor_id(void)
81 /* we don't want to mark this access volatile - bad code generation */
82 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
84 # endif /* APIC_DEFINITION */
86 #else /* CONFIG_X86_LOCAL_APIC */
89 # define hard_smp_processor_id() 0
92 #endif /* CONFIG_X86_LOCAL_APIC */
94 #endif /* !ASSEMBLY */