Commit | Line | Data |
---|---|---|
77ef50a5 VN |
1 | #ifndef ASM_X86__SMP_H |
2 | #define ASM_X86__SMP_H | |
c27cfeff | 3 | #ifndef __ASSEMBLY__ |
53ebef49 | 4 | #include <linux/cpumask.h> |
93b016f8 | 5 | #include <linux/init.h> |
7e1efc0c | 6 | #include <asm/percpu.h> |
53ebef49 | 7 | |
b23dab08 GC |
8 | /* |
9 | * We need the APIC definitions automatically as part of 'smp.h' | |
10 | */ | |
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> | |
16 | # endif | |
17 | #endif | |
18 | #include <asm/pda.h> | |
19 | #include <asm/thread_info.h> | |
20 | ||
53ebef49 | 21 | extern cpumask_t cpu_callout_map; |
8be9ac85 GC |
22 | extern cpumask_t cpu_initialized; |
23 | extern cpumask_t cpu_callin_map; | |
24 | ||
25 | extern void (*mtrr_hook)(void); | |
26 | extern void zap_low_mappings(void); | |
53ebef49 | 27 | |
7c33b1e6 JF |
28 | extern int __cpuinit get_local_pda(int cpu); |
29 | ||
53ebef49 GC |
30 | extern int smp_num_siblings; |
31 | extern unsigned int num_processors; | |
cb3c8b90 | 32 | extern cpumask_t cpu_initialized; |
c27cfeff | 33 | |
7e1efc0c GOC |
34 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); |
35 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); | |
36 | DECLARE_PER_CPU(u16, cpu_llc_id); | |
fb26132b JS |
37 | #ifdef CONFIG_X86_32 |
38 | DECLARE_PER_CPU(int, cpu_number); | |
39 | #endif | |
23ca4bba MT |
40 | |
41 | DECLARE_EARLY_PER_CPU(u16, x86_cpu_to_apicid); | |
42 | DECLARE_EARLY_PER_CPU(u16, x86_bios_cpu_apicid); | |
7e1efc0c | 43 | |
9d97d0da GOC |
44 | /* Static state in head.S used to set up a CPU */ |
45 | extern struct { | |
46 | void *sp; | |
47 | unsigned short ss; | |
48 | } stack_start; | |
49 | ||
16694024 GC |
50 | struct smp_ops { |
51 | void (*smp_prepare_boot_cpu)(void); | |
52 | void (*smp_prepare_cpus)(unsigned max_cpus); | |
16694024 GC |
53 | void (*smp_cpus_done)(unsigned max_cpus); |
54 | ||
55 | void (*smp_send_stop)(void); | |
56 | void (*smp_send_reschedule)(int cpu); | |
3b16cf87 | 57 | |
93be71b6 AN |
58 | int (*cpu_up)(unsigned cpu); |
59 | int (*cpu_disable)(void); | |
60 | void (*cpu_die)(unsigned int cpu); | |
61 | void (*play_dead)(void); | |
62 | ||
3b16cf87 JA |
63 | void (*send_call_func_ipi)(cpumask_t mask); |
64 | void (*send_call_func_single_ipi)(int cpu); | |
16694024 GC |
65 | }; |
66 | ||
14522076 GC |
67 | /* Globals due to paravirt */ |
68 | extern void set_cpu_sibling_map(int cpu); | |
69 | ||
c76cb368 | 70 | #ifdef CONFIG_SMP |
d0173aea GOC |
71 | #ifndef CONFIG_PARAVIRT |
72 | #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0) | |
73 | #endif | |
c76cb368 | 74 | extern struct smp_ops smp_ops; |
8678969e | 75 | |
377d6984 GC |
76 | static inline void smp_send_stop(void) |
77 | { | |
78 | smp_ops.smp_send_stop(); | |
79 | } | |
80 | ||
1e3fac83 GC |
81 | static inline void smp_prepare_boot_cpu(void) |
82 | { | |
83 | smp_ops.smp_prepare_boot_cpu(); | |
84 | } | |
85 | ||
7557da67 GC |
86 | static inline void smp_prepare_cpus(unsigned int max_cpus) |
87 | { | |
88 | smp_ops.smp_prepare_cpus(max_cpus); | |
89 | } | |
90 | ||
c5597649 GC |
91 | static inline void smp_cpus_done(unsigned int max_cpus) |
92 | { | |
93 | smp_ops.smp_cpus_done(max_cpus); | |
94 | } | |
95 | ||
71d19549 GC |
96 | static inline int __cpu_up(unsigned int cpu) |
97 | { | |
98 | return smp_ops.cpu_up(cpu); | |
99 | } | |
100 | ||
93be71b6 AN |
101 | static inline int __cpu_disable(void) |
102 | { | |
103 | return smp_ops.cpu_disable(); | |
104 | } | |
105 | ||
106 | static inline void __cpu_die(unsigned int cpu) | |
107 | { | |
108 | smp_ops.cpu_die(cpu); | |
109 | } | |
110 | ||
111 | static inline void play_dead(void) | |
112 | { | |
113 | smp_ops.play_dead(); | |
114 | } | |
115 | ||
8678969e GC |
116 | static inline void smp_send_reschedule(int cpu) |
117 | { | |
118 | smp_ops.smp_send_reschedule(cpu); | |
119 | } | |
64b1a21e | 120 | |
3b16cf87 JA |
121 | static inline void arch_send_call_function_single_ipi(int cpu) |
122 | { | |
123 | smp_ops.send_call_func_single_ipi(cpu); | |
124 | } | |
125 | ||
126 | static inline void arch_send_call_function_ipi(cpumask_t mask) | |
64b1a21e | 127 | { |
3b16cf87 | 128 | smp_ops.send_call_func_ipi(mask); |
64b1a21e | 129 | } |
71d19549 | 130 | |
8227dce7 | 131 | void cpu_disable_common(void); |
1e3fac83 | 132 | void native_smp_prepare_boot_cpu(void); |
7557da67 | 133 | void native_smp_prepare_cpus(unsigned int max_cpus); |
c5597649 | 134 | void native_smp_cpus_done(unsigned int max_cpus); |
71d19549 | 135 | int native_cpu_up(unsigned int cpunum); |
93be71b6 AN |
136 | int native_cpu_disable(void); |
137 | void native_cpu_die(unsigned int cpu); | |
138 | void native_play_dead(void); | |
a21f5d88 | 139 | void play_dead_common(void); |
93be71b6 | 140 | |
3b16cf87 JA |
141 | void native_send_call_func_ipi(cpumask_t mask); |
142 | void native_send_call_func_single_ipi(int cpu); | |
93b016f8 | 143 | |
1d89a7f0 | 144 | void smp_store_cpu_info(int id); |
c70dcb74 | 145 | #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) |
a9c057c1 GC |
146 | |
147 | /* We don't mark CPUs online until __cpu_up(), so we need another measure */ | |
148 | static inline int num_booting_cpus(void) | |
149 | { | |
150 | return cpus_weight(cpu_callout_map); | |
151 | } | |
4a701737 IM |
152 | #endif /* CONFIG_SMP */ |
153 | ||
154 | #if defined(CONFIG_SMP) && defined(CONFIG_HOTPLUG_CPU) | |
155 | extern void prefill_possible_map(void); | |
329513a3 YL |
156 | #else |
157 | static inline void prefill_possible_map(void) | |
158 | { | |
159 | } | |
4a701737 | 160 | #endif |
a9c057c1 | 161 | |
2fe60147 AS |
162 | extern unsigned disabled_cpus __cpuinitdata; |
163 | ||
a9c057c1 GC |
164 | #ifdef CONFIG_X86_32_SMP |
165 | /* | |
166 | * This function is needed by all SMP systems. It must _always_ be valid | |
167 | * from the initial startup. We map APIC_BASE very early in page_setup(), | |
168 | * so this is correct in the x86 case. | |
169 | */ | |
a9c057c1 GC |
170 | #define raw_smp_processor_id() (x86_read_percpu(cpu_number)) |
171 | extern int safe_smp_processor_id(void); | |
172 | ||
173 | #elif defined(CONFIG_X86_64_SMP) | |
174 | #define raw_smp_processor_id() read_pda(cpunumber) | |
175 | ||
176 | #define stack_smp_processor_id() \ | |
177 | ({ \ | |
178 | struct thread_info *ti; \ | |
179 | __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \ | |
180 | ti->cpu; \ | |
181 | }) | |
182 | #define safe_smp_processor_id() smp_processor_id() | |
183 | ||
184 | #else /* !CONFIG_X86_32_SMP && !CONFIG_X86_64_SMP */ | |
c70dcb74 | 185 | #define cpu_physical_id(cpu) boot_cpu_physical_apicid |
a9c057c1 GC |
186 | #define safe_smp_processor_id() 0 |
187 | #define stack_smp_processor_id() 0 | |
c76cb368 | 188 | #endif |
16694024 | 189 | |
1b000843 GC |
190 | #ifdef CONFIG_X86_LOCAL_APIC |
191 | ||
1b374e4d | 192 | #ifndef CONFIG_X86_64 |
1b000843 GC |
193 | static inline int logical_smp_processor_id(void) |
194 | { | |
195 | /* we don't want to mark this access volatile - bad code generation */ | |
196 | return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR)); | |
197 | } | |
198 | ||
4c9961d5 | 199 | #include <mach_apicdef.h> |
05f2d12c JS |
200 | static inline unsigned int read_apic_id(void) |
201 | { | |
4c9961d5 YL |
202 | unsigned int reg; |
203 | ||
204 | reg = *(u32 *)(APIC_BASE + APIC_ID); | |
205 | ||
206 | return GET_APIC_ID(reg); | |
05f2d12c | 207 | } |
ac23d4ee JS |
208 | #endif |
209 | ||
05f2d12c | 210 | |
0c81c746 | 211 | # if defined(APIC_DEFINITION) || defined(CONFIG_X86_64) |
1b000843 GC |
212 | extern int hard_smp_processor_id(void); |
213 | # else | |
4c9961d5 | 214 | #include <mach_apicdef.h> |
1b000843 GC |
215 | static inline int hard_smp_processor_id(void) |
216 | { | |
217 | /* we don't want to mark this access volatile - bad code generation */ | |
4c9961d5 | 218 | return read_apic_id(); |
1b000843 GC |
219 | } |
220 | # endif /* APIC_DEFINITION */ | |
221 | ||
222 | #else /* CONFIG_X86_LOCAL_APIC */ | |
223 | ||
224 | # ifndef CONFIG_SMP | |
225 | # define hard_smp_processor_id() 0 | |
226 | # endif | |
227 | ||
228 | #endif /* CONFIG_X86_LOCAL_APIC */ | |
229 | ||
c27cfeff | 230 | #endif /* __ASSEMBLY__ */ |
77ef50a5 | 231 | #endif /* ASM_X86__SMP_H */ |