x86: add x2apic config
[deliverable/linux.git] / arch / x86 / include / asm / apic.h
CommitLineData
1965aae3
PA
1#ifndef _ASM_X86_APIC_H
2#define _ASM_X86_APIC_H
67c5fc5c
TG
3
4#include <linux/pm.h>
5#include <linux/delay.h>
593f4a78
MR
6
7#include <asm/alternative.h>
67c5fc5c
TG
8#include <asm/fixmap.h>
9#include <asm/apicdef.h>
10#include <asm/processor.h>
11#include <asm/system.h>
13c88fb5
SS
12#include <asm/cpufeature.h>
13#include <asm/msr.h>
67c5fc5c
TG
14
15#define ARCH_APICTIMER_STOPS_ON_C3 1
16
67c5fc5c
TG
17/*
18 * Debugging macros
19 */
20#define APIC_QUIET 0
21#define APIC_VERBOSE 1
22#define APIC_DEBUG 2
23
24/*
25 * Define the default level of output to be very little
26 * This can be turned up by using apic=verbose for more
27 * information and apic=debug for _lots_ of information.
28 * apic_verbosity is defined in apic.c
29 */
30#define apic_printk(v, s, a...) do { \
31 if ((v) <= apic_verbosity) \
32 printk(s, ##a); \
33 } while (0)
34
35
160d8dac 36#if defined(CONFIG_X86_LOCAL_APIC) && defined(CONFIG_X86_32)
67c5fc5c 37extern void generic_apic_probe(void);
160d8dac
IM
38#else
39static inline void generic_apic_probe(void)
40{
41}
42#endif
67c5fc5c
TG
43
44#ifdef CONFIG_X86_LOCAL_APIC
45
baa13188 46extern unsigned int apic_verbosity;
67c5fc5c 47extern int local_apic_timer_c2_ok;
67c5fc5c 48
3c999f14 49extern int disable_apic;
0939e4fd
IM
50
51#ifdef CONFIG_SMP
52extern void __inquire_remote_apic(int apicid);
53#else /* CONFIG_SMP */
54static inline void __inquire_remote_apic(int apicid)
55{
56}
57#endif /* CONFIG_SMP */
58
59static inline void default_inquire_remote_apic(int apicid)
60{
61 if (apic_verbosity >= APIC_DEBUG)
62 __inquire_remote_apic(apicid);
63}
64
67c5fc5c
TG
65/*
66 * Basic functions accessing APICs.
67 */
68#ifdef CONFIG_PARAVIRT
69#include <asm/paravirt.h>
96a388de 70#else
67c5fc5c
TG
71#define setup_boot_clock setup_boot_APIC_clock
72#define setup_secondary_clock setup_secondary_APIC_clock
96a388de 73#endif
67c5fc5c 74
aa7d8e25 75extern int is_vsmp_box(void);
2b97df06
JS
76extern void xapic_wait_icr_idle(void);
77extern u32 safe_xapic_wait_icr_idle(void);
2b97df06
JS
78extern void xapic_icr_write(u32, u32);
79extern int setup_profiling_timer(unsigned int);
aa7d8e25 80
1b374e4d 81static inline void native_apic_mem_write(u32 reg, u32 v)
67c5fc5c 82{
593f4a78 83 volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
67c5fc5c 84
593f4a78
MR
85 alternative_io("movl %0, %1", "xchgl %0, %1", X86_FEATURE_11AP,
86 ASM_OUTPUT2("=r" (v), "=m" (*addr)),
87 ASM_OUTPUT2("0" (v), "m" (*addr)));
67c5fc5c
TG
88}
89
1b374e4d 90static inline u32 native_apic_mem_read(u32 reg)
67c5fc5c
TG
91{
92 return *((volatile u32 *)(APIC_BASE + reg));
93}
94
13c88fb5
SS
95static inline void native_apic_msr_write(u32 reg, u32 v)
96{
97 if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
98 reg == APIC_LVR)
99 return;
100
101 wrmsr(APIC_BASE_MSR + (reg >> 4), v, 0);
102}
103
104static inline u32 native_apic_msr_read(u32 reg)
105{
106 u32 low, high;
107
108 if (reg == APIC_DFR)
109 return -1;
110
111 rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
112 return low;
113}
114
06cd9a7d 115#ifdef CONFIG_X86_X2APIC
b6b301aa 116extern int x2apic;
6e1cb38a
SS
117extern void check_x2apic(void);
118extern void enable_x2apic(void);
119extern void enable_IR_x2apic(void);
120extern void x2apic_icr_write(u32 low, u32 id);
a11b5abe
YL
121static inline int x2apic_enabled(void)
122{
123 int msr, msr2;
124
125 if (!cpu_has_x2apic)
126 return 0;
127
128 rdmsr(MSR_IA32_APICBASE, msr, msr2);
129 if (msr & X2APIC_ENABLE)
130 return 1;
131 return 0;
132}
133#else
06cd9a7d
YL
134static inline void check_x2apic(void)
135{
136}
137static inline void enable_x2apic(void)
138{
139}
140static inline void enable_IR_x2apic(void)
141{
142}
143static inline int x2apic_enabled(void)
144{
145 return 0;
146}
c535b6a1 147#endif
1b374e4d
SS
148
149struct apic_ops {
150 u32 (*read)(u32 reg);
151 void (*write)(u32 reg, u32 v);
1b374e4d
SS
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
3c552ac8
JF
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}
1b374e4d 189
67c5fc5c
TG
190extern int get_physical_broadcast(void);
191
06cd9a7d 192#ifdef CONFIG_X86_X2APIC
89027d35
SS
193static inline void ack_x2APIC_irq(void)
194{
195 /* Docs say use 0 for future compatibility */
196 native_apic_msr_write(APIC_EOI, 0);
197}
198#endif
199
200
67c5fc5c
TG
201static inline void ack_APIC_irq(void)
202{
203 /*
0791e13f 204 * ack_APIC_irq() actually gets compiled as a single instruction
67c5fc5c
TG
205 * ... yummie.
206 */
207
208 /* Docs say use 0 for future compatibility */
593f4a78 209 apic_write(APIC_EOI, 0);
67c5fc5c
TG
210}
211
212extern int lapic_get_maxlvt(void);
213extern void clear_local_APIC(void);
214extern void connect_bsp_APIC(void);
215extern void disconnect_bsp_APIC(int virt_wire_setup);
216extern void disable_local_APIC(void);
217extern void lapic_shutdown(void);
218extern int verify_local_APIC(void);
219extern void cache_APIC_registers(void);
220extern void sync_Arb_IDs(void);
221extern void init_bsp_APIC(void);
222extern void setup_local_APIC(void);
739f33b3 223extern void end_local_APIC_setup(void);
67c5fc5c 224extern void init_apic_mappings(void);
67c5fc5c
TG
225extern void setup_boot_APIC_clock(void);
226extern void setup_secondary_APIC_clock(void);
227extern int APIC_init_uniprocessor(void);
e9427101 228extern void enable_NMI_through_LVT0(void);
67c5fc5c
TG
229
230/*
231 * On 32bit this is mach-xxx local
232 */
233#ifdef CONFIG_X86_64
8643f9d0 234extern void early_init_lapic_mapping(void);
8fbbc4b4
AK
235extern int apic_is_clustered_box(void);
236#else
237static inline int apic_is_clustered_box(void)
238{
239 return 0;
240}
67c5fc5c
TG
241#endif
242
7b83dae7
RR
243extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
244extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
67c5fc5c 245
67c5fc5c
TG
246
247#else /* !CONFIG_X86_LOCAL_APIC */
248static inline void lapic_shutdown(void) { }
249#define local_apic_timer_c2_ok 1
f3294a33 250static inline void init_apic_mappings(void) { }
d3ec5cae 251static inline void disable_local_APIC(void) { }
67c5fc5c
TG
252
253#endif /* !CONFIG_X86_LOCAL_APIC */
254
1f75ed0c
IM
255#ifdef CONFIG_X86_64
256#define SET_APIC_ID(x) (apic->set_apic_id(x))
257#else
258
6bda2c8b 259#ifdef CONFIG_X86_LOCAL_APIC
1dcdd3d1 260static inline unsigned default_get_apic_id(unsigned long x)
1f75ed0c
IM
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}
6bda2c8b 269#endif
1f75ed0c
IM
270
271#endif
272
1965aae3 273#endif /* _ASM_X86_APIC_H */
This page took 0.276566 seconds and 5 git commands to generate.