aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/apic.h
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2009-02-17 02:02:14 -0500
committerIngo Molnar <mingo@elte.hu>2009-02-17 06:22:20 -0500
commitc1eeb2de41d7015678bdd412b48a5f071b84e29a (patch)
tree6af99f46f557f9e854e882deac52d23b2fadb5a2 /arch/x86/include/asm/apic.h
parent06cd9a7dc8a58186060a91b6ddc031057435fd34 (diff)
x86: fold apic_ops into genapic
Impact: cleanup make it simpler, don't need have one extra struct. v2: fix the sgi_uv build Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/include/asm/apic.h')
-rw-r--r--arch/x86/include/asm/apic.h97
1 files changed, 31 insertions, 66 deletions
diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
index dc1db99cd40e..4f56e053d347 100644
--- a/arch/x86/include/asm/apic.h
+++ b/arch/x86/include/asm/apic.h
@@ -92,6 +92,12 @@ static inline u32 native_apic_mem_read(u32 reg)
92 return *((volatile u32 *)(APIC_BASE + reg)); 92 return *((volatile u32 *)(APIC_BASE + reg));
93} 93}
94 94
95extern void native_apic_wait_icr_idle(void);
96extern u32 native_safe_apic_wait_icr_idle(void);
97extern void native_apic_icr_write(u32 low, u32 id);
98extern u64 native_apic_icr_read(void);
99
100#ifdef CONFIG_X86_X2APIC
95static inline void native_apic_msr_write(u32 reg, u32 v) 101static inline void native_apic_msr_write(u32 reg, u32 v)
96{ 102{
97 if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR || 103 if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
@@ -112,7 +118,31 @@ static inline u32 native_apic_msr_read(u32 reg)
112 return low; 118 return low;
113} 119}
114 120
115#ifdef CONFIG_X86_X2APIC 121static inline void native_x2apic_wait_icr_idle(void)
122{
123 /* no need to wait for icr idle in x2apic */
124 return;
125}
126
127static inline u32 native_safe_x2apic_wait_icr_idle(void)
128{
129 /* no need to wait for icr idle in x2apic */
130 return 0;
131}
132
133static inline void native_x2apic_icr_write(u32 low, u32 id)
134{
135 wrmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), ((__u64) id) << 32 | low);
136}
137
138static inline u64 native_x2apic_icr_read(void)
139{
140 unsigned long val;
141
142 rdmsrl(APIC_BASE_MSR + (APIC_ICR >> 4), val);
143 return val;
144}
145
116extern int x2apic; 146extern int x2apic;
117extern void check_x2apic(void); 147extern void check_x2apic(void);
118extern void enable_x2apic(void); 148extern void enable_x2apic(void);
@@ -146,47 +176,6 @@ static inline int x2apic_enabled(void)
146} 176}
147#endif 177#endif
148 178
149struct apic_ops {
150 u32 (*read)(u32 reg);
151 void (*write)(u32 reg, u32 v);
152 u64 (*icr_read)(void);
153 void (*icr_write)(u32 low, u32 high);
154 void (*wait_icr_idle)(void);
155 u32 (*safe_wait_icr_idle)(void);
156};
157
158extern struct apic_ops *apic_ops;
159
160static inline u32 apic_read(u32 reg)
161{
162 return apic_ops->read(reg);
163}
164
165static inline void apic_write(u32 reg, u32 val)
166{
167 apic_ops->write(reg, val);
168}
169
170static inline u64 apic_icr_read(void)
171{
172 return apic_ops->icr_read();
173}
174
175static inline void apic_icr_write(u32 low, u32 high)
176{
177 apic_ops->icr_write(low, high);
178}
179
180static inline void apic_wait_icr_idle(void)
181{
182 apic_ops->wait_icr_idle();
183}
184
185static inline u32 safe_apic_wait_icr_idle(void)
186{
187 return apic_ops->safe_wait_icr_idle();
188}
189
190extern int get_physical_broadcast(void); 179extern int get_physical_broadcast(void);
191 180
192#ifdef CONFIG_X86_X2APIC 181#ifdef CONFIG_X86_X2APIC
@@ -197,18 +186,6 @@ static inline void ack_x2APIC_irq(void)
197} 186}
198#endif 187#endif
199 188
200
201static inline void ack_APIC_irq(void)
202{
203 /*
204 * ack_APIC_irq() actually gets compiled as a single instruction
205 * ... yummie.
206 */
207
208 /* Docs say use 0 for future compatibility */
209 apic_write(APIC_EOI, 0);
210}
211
212extern int lapic_get_maxlvt(void); 189extern int lapic_get_maxlvt(void);
213extern void clear_local_APIC(void); 190extern void clear_local_APIC(void);
214extern void connect_bsp_APIC(void); 191extern void connect_bsp_APIC(void);
@@ -256,18 +233,6 @@ static inline void disable_local_APIC(void) { }
256#define SET_APIC_ID(x) (apic->set_apic_id(x)) 233#define SET_APIC_ID(x) (apic->set_apic_id(x))
257#else 234#else
258 235
259#ifdef CONFIG_X86_LOCAL_APIC
260static inline unsigned default_get_apic_id(unsigned long x)
261{
262 unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));
263
264 if (APIC_XAPIC(ver))
265 return (x >> 24) & 0xFF;
266 else
267 return (x >> 24) & 0x0F;
268}
269#endif
270
271#endif 236#endif
272 237
273#endif /* _ASM_X86_APIC_H */ 238#endif /* _ASM_X86_APIC_H */