]> err.no Git - linux-2.6/blob - include/asm-x86/smp_32.h
x86: define smp_ops in common header
[linux-2.6] / include / asm-x86 / smp_32.h
1 #ifndef __ASM_SMP_H
2 #define __ASM_SMP_H
3
4 #ifndef __ASSEMBLY__
5 #include <linux/cpumask.h>
6 #include <linux/init.h>
7
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
19 extern cpumask_t cpu_callin_map;
20
21 extern void (*mtrr_hook) (void);
22 extern void zap_low_mappings (void);
23
24 extern u8 __initdata x86_cpu_to_apicid_init[];
25 extern void *x86_cpu_to_apicid_early_ptr;
26
27 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
28 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
29 DECLARE_PER_CPU(u8, cpu_llc_id);
30 DECLARE_PER_CPU(u8, x86_cpu_to_apicid);
31
32 #ifdef CONFIG_HOTPLUG_CPU
33 extern void cpu_exit_clear(void);
34 extern void cpu_uninit(void);
35 extern void remove_siblinginfo(int cpu);
36 #endif
37
38 /* Globals due to paravirt */
39 extern void set_cpu_sibling_map(int cpu);
40
41 #ifdef CONFIG_SMP
42 extern struct smp_ops smp_ops;
43
44 static inline void smp_prepare_boot_cpu(void)
45 {
46         smp_ops.smp_prepare_boot_cpu();
47 }
48 static inline void smp_prepare_cpus(unsigned int max_cpus)
49 {
50         smp_ops.smp_prepare_cpus(max_cpus);
51 }
52 static inline int __cpu_up(unsigned int cpu)
53 {
54         return smp_ops.cpu_up(cpu);
55 }
56 static inline void smp_cpus_done(unsigned int max_cpus)
57 {
58         smp_ops.smp_cpus_done(max_cpus);
59 }
60
61 static inline void smp_send_stop(void)
62 {
63         smp_ops.smp_send_stop();
64 }
65 static inline void smp_send_reschedule(int cpu)
66 {
67         smp_ops.smp_send_reschedule(cpu);
68 }
69 static inline int smp_call_function_mask(cpumask_t mask,
70                                          void (*func) (void *info), void *info,
71                                          int wait)
72 {
73         return smp_ops.smp_call_function_mask(mask, func, info, wait);
74 }
75
76 void native_smp_prepare_boot_cpu(void);
77 void native_smp_prepare_cpus(unsigned int max_cpus);
78 int native_cpu_up(unsigned int cpunum);
79 void native_smp_cpus_done(unsigned int max_cpus);
80
81 #ifndef CONFIG_PARAVIRT
82 #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
83 #endif
84
85 extern int __cpu_disable(void);
86 extern void __cpu_die(unsigned int cpu);
87
88 /*
89  * This function is needed by all SMP systems. It must _always_ be valid
90  * from the initial startup. We map APIC_BASE very early in page_setup(),
91  * so this is correct in the x86 case.
92  */
93 DECLARE_PER_CPU(int, cpu_number);
94 #define raw_smp_processor_id() (x86_read_percpu(cpu_number))
95
96 #define cpu_physical_id(cpu)    per_cpu(x86_cpu_to_apicid, cpu)
97
98 extern int safe_smp_processor_id(void);
99
100 void __cpuinit smp_store_cpu_info(int id);
101
102 /* We don't mark CPUs online until __cpu_up(), so we need another measure */
103 static inline int num_booting_cpus(void)
104 {
105         return cpus_weight(cpu_callout_map);
106 }
107
108 #else /* CONFIG_SMP */
109
110 #define safe_smp_processor_id()         0
111 #define cpu_physical_id(cpu)            boot_cpu_physical_apicid
112
113 #endif /* !CONFIG_SMP */
114
115 #ifdef CONFIG_X86_LOCAL_APIC
116
117 static __inline int logical_smp_processor_id(void)
118 {
119         /* we don't want to mark this access volatile - bad code generation */
120         return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
121 }
122
123 # ifdef APIC_DEFINITION
124 extern int hard_smp_processor_id(void);
125 # else
126 #  include <mach_apicdef.h>
127 static inline int hard_smp_processor_id(void)
128 {
129         /* we don't want to mark this access volatile - bad code generation */
130         return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
131 }
132 # endif /* APIC_DEFINITION */
133
134 #else /* CONFIG_X86_LOCAL_APIC */
135
136 # ifndef CONFIG_SMP
137 #  define hard_smp_processor_id()       0
138 # endif
139
140 #endif /* CONFIG_X86_LOCAL_APIC */
141
142 #endif /* !ASSEMBLY */
143 #endif