]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - include/asm-x86/smp_64.h
x86: cleanup smp.h variants
[linux-2.6-omap-h63xx.git] / 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_callout_map;
17 extern cpumask_t cpu_initialized;
18
19 extern int smp_num_siblings;
20 extern unsigned int num_processors;
21
22 extern void smp_alloc_memory(void);
23 extern void lock_ipi_call_lock(void);
24 extern void unlock_ipi_call_lock(void);
25
26 extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *),
27                                   void *info, int wait);
28
29 extern u8 __initdata x86_cpu_to_apicid_init[];
30 extern void *x86_cpu_to_apicid_ptr;
31 extern u8 bios_cpu_apicid[];
32
33 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
34 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
35 DECLARE_PER_CPU(u8, cpu_llc_id);
36 DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
37
38 static inline int cpu_present_to_apicid(int mps_cpu)
39 {
40         if (mps_cpu < NR_CPUS)
41                 return (int)bios_cpu_apicid[mps_cpu];
42         else
43                 return BAD_APICID;
44 }
45
46 #ifdef CONFIG_SMP
47
48 #define SMP_TRAMPOLINE_BASE 0x6000
49
50 extern int __cpu_disable(void);
51 extern void __cpu_die(unsigned int cpu);
52 extern void prefill_possible_map(void);
53 extern unsigned __cpuinitdata disabled_cpus;
54
55 #define raw_smp_processor_id()  read_pda(cpunumber)
56 #define cpu_physical_id(cpu)    per_cpu(x86_cpu_to_apicid, cpu)
57
58 #define stack_smp_processor_id()                                        \
59         ({                                                              \
60         struct thread_info *ti;                                         \
61         __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK));      \
62         ti->cpu;                                                        \
63 })
64
65 /*
66  * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies
67  * scheduling and IPI sending and compresses data structures.
68  */
69 static inline int num_booting_cpus(void)
70 {
71         return cpus_weight(cpu_callout_map);
72 }
73
74 extern void smp_send_reschedule(int cpu);
75
76 #else /* CONFIG_SMP */
77
78 extern unsigned int boot_cpu_id;
79 #define cpu_physical_id(cpu)    boot_cpu_id
80 #define stack_smp_processor_id() 0
81
82 #endif /* !CONFIG_SMP */
83
84 #define safe_smp_processor_id()         smp_processor_id()
85
86 static __inline int logical_smp_processor_id(void)
87 {
88         /* we don't want to mark this access volatile - bad code generation */
89         return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
90 }
91
92 static inline int hard_smp_processor_id(void)
93 {
94         /* we don't want to mark this access volatile - bad code generation */
95         return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
96 }
97
98 #endif
99