x86: move prefill_possible_map to common file
[safe/jmp/linux-2.6] / include / asm-x86 / smp_64.h
1 #ifndef __ASM_SMP_H
2 #define __ASM_SMP_H
3
4 #include <linux/cpumask.h>
5 #include <linux/init.h>
6
7 /*
8  * We need the APIC definitions automatically as part of 'smp.h'
9  */
10 #include <asm/apic.h>
11 #include <asm/io_apic.h>
12 #include <asm/mpspec.h>
13 #include <asm/pda.h>
14 #include <asm/thread_info.h>
15
16 extern cpumask_t cpu_initialized;
17
18 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
19                                   void *info, int wait);
20
21 extern u16 __initdata x86_cpu_to_apicid_init[];
22 extern u16 __initdata x86_bios_cpu_apicid_init[];
23 extern void *x86_cpu_to_apicid_early_ptr;
24 extern void *x86_bios_cpu_apicid_early_ptr;
25
26 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
27 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
28 DECLARE_PER_CPU(u16, cpu_llc_id);
29 DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
30 DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
31
32 static inline int cpu_present_to_apicid(int mps_cpu)
33 {
34         if (cpu_present(mps_cpu))
35                 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
36         else
37                 return BAD_APICID;
38 }
39
40 #ifdef CONFIG_SMP
41
42 #define SMP_TRAMPOLINE_BASE 0x6000
43
44 extern int __cpu_disable(void);
45 extern void __cpu_die(unsigned int cpu);
46
47 #define raw_smp_processor_id()  read_pda(cpunumber)
48 #define cpu_physical_id(cpu)    per_cpu(x86_cpu_to_apicid, cpu)
49
50 #define stack_smp_processor_id()                                        \
51         ({                                                              \
52         struct thread_info *ti;                                         \
53         __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK));      \
54         ti->cpu;                                                        \
55 })
56
57 /*
58  * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
59  * scheduling and IPI sending and compresses data structures.
60  */
61 static inline int num_booting_cpus(void)
62 {
63         return cpus_weight(cpu_callout_map);
64 }
65
66 #else /* CONFIG_SMP */
67
68 extern unsigned int boot_cpu_id;
69 #define cpu_physical_id(cpu)    boot_cpu_id
70 #define stack_smp_processor_id() 0
71
72 #endif /* !CONFIG_SMP */
73
74 #define safe_smp_processor_id()         smp_processor_id()
75
76 static __inline int logical_smp_processor_id(void)
77 {
78         /* we don't want to mark this access volatile - bad code generation */
79         return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
80 }
81
82 static inline int hard_smp_processor_id(void)
83 {
84         /* we don't want to mark this access volatile - bad code generation */
85         return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
86 }
87
88 #endif
89