x86: include mach_apic.h in smpboot_64.c and smpboot.c
[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 extern cpumask_t cpu_callin_map;
18
19 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
20                                   void *info, int wait);
21
22 #ifdef CONFIG_SMP
23
24 #define raw_smp_processor_id()  read_pda(cpunumber)
25 #define cpu_physical_id(cpu)    per_cpu(x86_cpu_to_apicid, cpu)
26
27 #define stack_smp_processor_id()                                        \
28         ({                                                              \
29         struct thread_info *ti;                                         \
30         __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK));      \
31         ti->cpu;                                                        \
32 })
33
34 /*
35  * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
36  * scheduling and IPI sending and compresses data structures.
37  */
38 static inline int num_booting_cpus(void)
39 {
40         return cpus_weight(cpu_callout_map);
41 }
42
43 #else /* CONFIG_SMP */
44
45 extern unsigned int boot_cpu_id;
46 #define cpu_physical_id(cpu)    boot_cpu_id
47 #define stack_smp_processor_id() 0
48
49 #endif /* !CONFIG_SMP */
50
51 #define safe_smp_processor_id()         smp_processor_id()
52
53 static __inline int logical_smp_processor_id(void)
54 {
55         /* we don't want to mark this access volatile - bad code generation */
56         return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
57 }
58
59 #include <mach_apicdef.h>
60 static inline int hard_smp_processor_id(void)
61 {
62         /* we don't want to mark this access volatile - bad code generation */
63         return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
64 }
65
66 #endif
67