blob: fcd2f01277b623fcd7ef5e0aa25b6fb7cca17404 [file] [log] [blame]
Thomas Gleixner67c5fc52008-01-30 13:30:15 +01001#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>
Suresh Siddha13c88fb52008-07-10 11:16:52 -070010#include <asm/cpufeature.h>
11#include <asm/msr.h>
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010012
13#define ARCH_APICTIMER_STOPS_ON_C3 1
14
15#define Dprintk(x...)
16
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
36extern void generic_apic_probe(void);
37
38#ifdef CONFIG_X86_LOCAL_APIC
39
40extern int apic_verbosity;
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010041extern int local_apic_timer_c2_ok;
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010042
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010043extern int ioapic_force;
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010044
Yinghai Lu3c999f12008-06-20 16:11:20 -070045extern int disable_apic;
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010046/*
47 * Basic functions accessing APICs.
48 */
49#ifdef CONFIG_PARAVIRT
50#include <asm/paravirt.h>
Thomas Gleixner96a388d2007-10-11 11:20:03 +020051#else
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010052#define setup_boot_clock setup_boot_APIC_clock
53#define setup_secondary_clock setup_secondary_APIC_clock
Thomas Gleixner96a388d2007-10-11 11:20:03 +020054#endif
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010055
Ravikiran G Thirumalaiaa7d8e25e2008-03-20 00:41:16 -070056extern int is_vsmp_box(void);
57
Suresh Siddha1b374e42008-07-10 11:16:49 -070058static inline void native_apic_mem_write(u32 reg, u32 v)
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010059{
60 *((volatile u32 *)(APIC_BASE + reg)) = v;
61}
62
Suresh Siddha1b374e42008-07-10 11:16:49 -070063static inline void native_apic_mem_write_atomic(u32 reg, u32 v)
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010064{
Joe Perches3c311fe2008-03-23 01:01:40 -070065 (void)xchg((u32 *)(APIC_BASE + reg), v);
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010066}
67
Suresh Siddha1b374e42008-07-10 11:16:49 -070068static inline u32 native_apic_mem_read(u32 reg)
Thomas Gleixner67c5fc52008-01-30 13:30:15 +010069{
70 return *((volatile u32 *)(APIC_BASE + reg));
71}
72
Suresh Siddha13c88fb52008-07-10 11:16:52 -070073static inline void native_apic_msr_write(u32 reg, u32 v)
74{
75 if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
76 reg == APIC_LVR)
77 return;
78
79 wrmsr(APIC_BASE_MSR + (reg >> 4), v, 0);
80}
81
82static inline u32 native_apic_msr_read(u32 reg)
83{
84 u32 low, high;
85
86 if (reg == APIC_DFR)
87 return -1;
88
89 rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
90 return low;
91}
92
Yinghai Luc535b6a2008-07-11 18:41:54 -070093#ifndef CONFIG_X86_32
Suresh Siddha6e1cb382008-07-10 11:16:58 -070094extern int x2apic, x2apic_preenabled;
95extern void check_x2apic(void);
96extern void enable_x2apic(void);
97extern void enable_IR_x2apic(void);
98extern void x2apic_icr_write(u32 low, u32 id);
Yinghai Luc535b6a2008-07-11 18:41:54 -070099#endif
Suresh Siddha1b374e42008-07-10 11:16:49 -0700100
101struct apic_ops {
102 u32 (*read)(u32 reg);
103 void (*write)(u32 reg, u32 v);
104 void (*write_atomic)(u32 reg, u32 v);
105 u64 (*icr_read)(void);
106 void (*icr_write)(u32 low, u32 high);
107 void (*wait_icr_idle)(void);
108 u32 (*safe_wait_icr_idle)(void);
109};
110
111extern struct apic_ops *apic_ops;
112
113#define apic_read (apic_ops->read)
114#define apic_write (apic_ops->write)
115#define apic_write_atomic (apic_ops->write_atomic)
116#define apic_icr_read (apic_ops->icr_read)
117#define apic_icr_write (apic_ops->icr_write)
118#define apic_wait_icr_idle (apic_ops->wait_icr_idle)
119#define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle)
Suresh Siddha1b374e42008-07-10 11:16:49 -0700120
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100121extern int get_physical_broadcast(void);
122
123#ifdef CONFIG_X86_GOOD_APIC
124# define FORCE_READ_AROUND_WRITE 0
125# define apic_read_around(x)
126# define apic_write_around(x, y) apic_write((x), (y))
127#else
128# define FORCE_READ_AROUND_WRITE 1
129# define apic_read_around(x) apic_read(x)
130# define apic_write_around(x, y) apic_write_atomic((x), (y))
131#endif
132
Suresh Siddha89027d32008-07-10 11:16:56 -0700133#ifdef CONFIG_X86_64
134static inline void ack_x2APIC_irq(void)
135{
136 /* Docs say use 0 for future compatibility */
137 native_apic_msr_write(APIC_EOI, 0);
138}
139#endif
140
141
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100142static inline void ack_APIC_irq(void)
143{
144 /*
145 * ack_APIC_irq() actually gets compiled as a single instruction:
146 * - a single rmw on Pentium/82489DX
147 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
148 * ... yummie.
149 */
150
151 /* Docs say use 0 for future compatibility */
Suresh Siddha1b374e42008-07-10 11:16:49 -0700152#ifdef CONFIG_X86_32
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100153 apic_write_around(APIC_EOI, 0);
Suresh Siddha1b374e42008-07-10 11:16:49 -0700154#else
155 native_apic_mem_write(APIC_EOI, 0);
156#endif
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100157}
158
159extern int lapic_get_maxlvt(void);
160extern void clear_local_APIC(void);
161extern void connect_bsp_APIC(void);
162extern void disconnect_bsp_APIC(int virt_wire_setup);
163extern void disable_local_APIC(void);
164extern void lapic_shutdown(void);
165extern int verify_local_APIC(void);
166extern void cache_APIC_registers(void);
167extern void sync_Arb_IDs(void);
168extern void init_bsp_APIC(void);
169extern void setup_local_APIC(void);
Andi Kleen739f33b2008-01-30 13:30:40 +0100170extern void end_local_APIC_setup(void);
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100171extern void init_apic_mappings(void);
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100172extern void setup_boot_APIC_clock(void);
173extern void setup_secondary_APIC_clock(void);
174extern int APIC_init_uniprocessor(void);
Jan Beuliche9427102008-01-30 13:31:24 +0100175extern void enable_NMI_through_LVT0(void);
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100176
177/*
178 * On 32bit this is mach-xxx local
179 */
180#ifdef CONFIG_X86_64
Yinghai Lu8643f9d2008-02-19 03:21:06 -0800181extern void early_init_lapic_mapping(void);
Alok Kataria8fbbc4b2008-07-01 11:43:34 -0700182extern int apic_is_clustered_box(void);
183#else
184static inline int apic_is_clustered_box(void)
185{
186 return 0;
187}
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100188#endif
189
Robert Richter7b83dae2008-01-30 13:30:40 +0100190extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
191extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100192
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100193
194#else /* !CONFIG_X86_LOCAL_APIC */
195static inline void lapic_shutdown(void) { }
196#define local_apic_timer_c2_ok 1
Yinghai Luf3294a32008-06-27 01:41:56 -0700197static inline void init_apic_mappings(void) { }
Thomas Gleixner67c5fc52008-01-30 13:30:15 +0100198
199#endif /* !CONFIG_X86_LOCAL_APIC */
200
201#endif /* __ASM_APIC_H */