Merge branch 'x86/core' into x86/xsave
[deliverable/linux.git] / include / asm-x86 / apic.h
CommitLineData
77ef50a5
VN
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
36extern void generic_apic_probe(void);
37
38#ifdef CONFIG_X86_LOCAL_APIC
39
baa13188 40extern unsigned int apic_verbosity;
67c5fc5c 41extern int local_apic_timer_c2_ok;
67c5fc5c 42
67c5fc5c 43extern int ioapic_force;
67c5fc5c 44
3c999f14 45extern int disable_apic;
67c5fc5c
TG
46/*
47 * Basic functions accessing APICs.
48 */
49#ifdef CONFIG_PARAVIRT
50#include <asm/paravirt.h>
96a388de 51#else
67c5fc5c
TG
52#define setup_boot_clock setup_boot_APIC_clock
53#define setup_secondary_clock setup_secondary_APIC_clock
96a388de 54#endif
67c5fc5c 55
aa7d8e25
RT
56extern int is_vsmp_box(void);
57
1b374e4d 58static inline void native_apic_mem_write(u32 reg, u32 v)
67c5fc5c 59{
593f4a78 60 volatile u32 *addr = (volatile u32 *)(APIC_BASE + reg);
67c5fc5c 61
593f4a78
MR
62 alternative_io("movl %0, %1", "xchgl %0, %1", X86_FEATURE_11AP,
63 ASM_OUTPUT2("=r" (v), "=m" (*addr)),
64 ASM_OUTPUT2("0" (v), "m" (*addr)));
67c5fc5c
TG
65}
66
1b374e4d 67static inline u32 native_apic_mem_read(u32 reg)
67c5fc5c
TG
68{
69 return *((volatile u32 *)(APIC_BASE + reg));
70}
71
13c88fb5
SS
72static inline void native_apic_msr_write(u32 reg, u32 v)
73{
74 if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR ||
75 reg == APIC_LVR)
76 return;
77
78 wrmsr(APIC_BASE_MSR + (reg >> 4), v, 0);
79}
80
81static inline u32 native_apic_msr_read(u32 reg)
82{
83 u32 low, high;
84
85 if (reg == APIC_DFR)
86 return -1;
87
88 rdmsr(APIC_BASE_MSR + (reg >> 4), low, high);
89 return low;
90}
91
c535b6a1 92#ifndef CONFIG_X86_32
6e1cb38a
SS
93extern int x2apic, x2apic_preenabled;
94extern void check_x2apic(void);
95extern void enable_x2apic(void);
96extern void enable_IR_x2apic(void);
97extern void x2apic_icr_write(u32 low, u32 id);
c535b6a1 98#endif
1b374e4d
SS
99
100struct apic_ops {
101 u32 (*read)(u32 reg);
102 void (*write)(u32 reg, u32 v);
1b374e4d
SS
103 u64 (*icr_read)(void);
104 void (*icr_write)(u32 low, u32 high);
105 void (*wait_icr_idle)(void);
106 u32 (*safe_wait_icr_idle)(void);
107};
108
109extern struct apic_ops *apic_ops;
110
111#define apic_read (apic_ops->read)
112#define apic_write (apic_ops->write)
1b374e4d
SS
113#define apic_icr_read (apic_ops->icr_read)
114#define apic_icr_write (apic_ops->icr_write)
115#define apic_wait_icr_idle (apic_ops->wait_icr_idle)
116#define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle)
1b374e4d 117
67c5fc5c
TG
118extern int get_physical_broadcast(void);
119
89027d35
SS
120#ifdef CONFIG_X86_64
121static inline void ack_x2APIC_irq(void)
122{
123 /* Docs say use 0 for future compatibility */
124 native_apic_msr_write(APIC_EOI, 0);
125}
126#endif
127
128
67c5fc5c
TG
129static inline void ack_APIC_irq(void)
130{
131 /*
132 * ack_APIC_irq() actually gets compiled as a single instruction:
133 * - a single rmw on Pentium/82489DX
134 * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC)
135 * ... yummie.
136 */
137
138 /* Docs say use 0 for future compatibility */
593f4a78 139 apic_write(APIC_EOI, 0);
67c5fc5c
TG
140}
141
142extern int lapic_get_maxlvt(void);
143extern void clear_local_APIC(void);
144extern void connect_bsp_APIC(void);
145extern void disconnect_bsp_APIC(int virt_wire_setup);
146extern void disable_local_APIC(void);
147extern void lapic_shutdown(void);
148extern int verify_local_APIC(void);
149extern void cache_APIC_registers(void);
150extern void sync_Arb_IDs(void);
151extern void init_bsp_APIC(void);
152extern void setup_local_APIC(void);
739f33b3 153extern void end_local_APIC_setup(void);
67c5fc5c 154extern void init_apic_mappings(void);
67c5fc5c
TG
155extern void setup_boot_APIC_clock(void);
156extern void setup_secondary_APIC_clock(void);
157extern int APIC_init_uniprocessor(void);
e9427101 158extern void enable_NMI_through_LVT0(void);
67c5fc5c
TG
159
160/*
161 * On 32bit this is mach-xxx local
162 */
163#ifdef CONFIG_X86_64
8643f9d0 164extern void early_init_lapic_mapping(void);
8fbbc4b4
AK
165extern int apic_is_clustered_box(void);
166#else
167static inline int apic_is_clustered_box(void)
168{
169 return 0;
170}
67c5fc5c
TG
171#endif
172
7b83dae7
RR
173extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask);
174extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask);
67c5fc5c 175
67c5fc5c
TG
176
177#else /* !CONFIG_X86_LOCAL_APIC */
178static inline void lapic_shutdown(void) { }
179#define local_apic_timer_c2_ok 1
f3294a33 180static inline void init_apic_mappings(void) { }
67c5fc5c
TG
181
182#endif /* !CONFIG_X86_LOCAL_APIC */
183
77ef50a5 184#endif /* ASM_X86__APIC_H */
This page took 0.184042 seconds and 5 git commands to generate.