x64, x2apic/intr-remap: basic apic ops support
[linux-2.6] / include / asm-x86 / apic.h
1 #ifndef _ASM_X86_APIC_H
2 #define _ASM_X86_APIC_H
3
4 #include <linux/pm.h>
5 #include <linux/delay.h>
6 #include <asm/fixmap.h>
7 #include <asm/apicdef.h>
8 #include <asm/processor.h>
9 #include <asm/system.h>
10
11 #define ARCH_APICTIMER_STOPS_ON_C3      1
12
13 #define Dprintk(x...)
14
15 /*
16  * Debugging macros
17  */
18 #define APIC_QUIET   0
19 #define APIC_VERBOSE 1
20 #define APIC_DEBUG   2
21
22 /*
23  * Define the default level of output to be very little
24  * This can be turned up by using apic=verbose for more
25  * information and apic=debug for _lots_ of information.
26  * apic_verbosity is defined in apic.c
27  */
28 #define apic_printk(v, s, a...) do {       \
29                 if ((v) <= apic_verbosity) \
30                         printk(s, ##a);    \
31         } while (0)
32
33
34 extern void generic_apic_probe(void);
35
36 #ifdef CONFIG_X86_LOCAL_APIC
37
38 extern int apic_verbosity;
39 extern int local_apic_timer_c2_ok;
40
41 extern int ioapic_force;
42
43 extern int disable_apic;
44 /*
45  * Basic functions accessing APICs.
46  */
47 #ifdef CONFIG_PARAVIRT
48 #include <asm/paravirt.h>
49 #else
50 #ifndef CONFIG_X86_64
51 #define apic_write native_apic_mem_write
52 #define apic_write_atomic native_apic_mem_write_atomic
53 #define apic_read native_apic_mem_read
54 #endif
55 #define setup_boot_clock setup_boot_APIC_clock
56 #define setup_secondary_clock setup_secondary_APIC_clock
57 #endif
58
59 extern int is_vsmp_box(void);
60
61 static inline void native_apic_mem_write(u32 reg, u32 v)
62 {
63         *((volatile u32 *)(APIC_BASE + reg)) = v;
64 }
65
66 static inline void native_apic_mem_write_atomic(u32 reg, u32 v)
67 {
68         (void)xchg((u32 *)(APIC_BASE + reg), v);
69 }
70
71 static inline u32 native_apic_mem_read(u32 reg)
72 {
73         return *((volatile u32 *)(APIC_BASE + reg));
74 }
75
76 #ifdef CONFIG_X86_32
77 extern void apic_wait_icr_idle(void);
78 extern u32 safe_apic_wait_icr_idle(void);
79 extern void apic_icr_write(u32 low, u32 id);
80 #else
81
82 struct apic_ops {
83         u32 (*read)(u32 reg);
84         void (*write)(u32 reg, u32 v);
85         void (*write_atomic)(u32 reg, u32 v);
86         u64 (*icr_read)(void);
87         void (*icr_write)(u32 low, u32 high);
88         void (*wait_icr_idle)(void);
89         u32 (*safe_wait_icr_idle)(void);
90 };
91
92 extern struct apic_ops *apic_ops;
93
94 #define apic_read (apic_ops->read)
95 #define apic_write (apic_ops->write)
96 #define apic_write_atomic (apic_ops->write_atomic)
97 #define apic_icr_read (apic_ops->icr_read)
98 #define apic_icr_write (apic_ops->icr_write)
99 #define apic_wait_icr_idle (apic_ops->wait_icr_idle)
100 #define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle)
101 #endif
102
103 extern int get_physical_broadcast(void);
104
105 #ifdef CONFIG_X86_GOOD_APIC
106 # define FORCE_READ_AROUND_WRITE 0
107 # define apic_read_around(x)
108 # define apic_write_around(x, y) apic_write((x), (y))
109 #else
110 # define FORCE_READ_AROUND_WRITE 1
111 # define apic_read_around(x) apic_read(x)
112 # define apic_write_around(x, y) apic_write_atomic((x), (y))
113 #endif
114
115 static inline void ack_APIC_irq(void)
116 {
117         /*
118          * ack_APIC_irq() actually gets compiled as a single instruction:
119          * - a single rmw on Pentium/82489DX
120          * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
121          * ... yummie.
122          */
123
124         /* Docs say use 0 for future compatibility */
125 #ifdef CONFIG_X86_32
126         apic_write_around(APIC_EOI, 0);
127 #else
128         native_apic_mem_write(APIC_EOI, 0);
129 #endif
130 }
131
132 extern int lapic_get_maxlvt(void);
133 extern void clear_local_APIC(void);
134 extern void connect_bsp_APIC(void);
135 extern void disconnect_bsp_APIC(int virt_wire_setup);
136 extern void disable_local_APIC(void);
137 extern void lapic_shutdown(void);
138 extern int verify_local_APIC(void);
139 extern void cache_APIC_registers(void);
140 extern void sync_Arb_IDs(void);
141 extern void init_bsp_APIC(void);
142 extern void setup_local_APIC(void);
143 extern void end_local_APIC_setup(void);
144 extern void init_apic_mappings(void);
145 extern void setup_boot_APIC_clock(void);
146 extern void setup_secondary_APIC_clock(void);
147 extern int APIC_init_uniprocessor(void);
148 extern void enable_NMI_through_LVT0(void);
149
150 /*
151  * On 32bit this is mach-xxx local
152  */
153 #ifdef CONFIG_X86_64
154 extern void early_init_lapic_mapping(void);
155 extern int apic_is_clustered_box(void);
156 #else
157 static inline int apic_is_clustered_box(void)
158 {
159         return 0;
160 }
161 #endif
162
163 extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
164 extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
165
166
167 #else /* !CONFIG_X86_LOCAL_APIC */
168 static inline void lapic_shutdown(void) { }
169 #define local_apic_timer_c2_ok          1
170 static inline void init_apic_mappings(void) { }
171
172 #endif /* !CONFIG_X86_LOCAL_APIC */
173
174 #endif /* __ASM_APIC_H */