Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 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> |
Suresh Siddha | 13c88fb | 2008-07-10 11:16:52 -0700 | [diff] [blame] | 10 | #include <asm/cpufeature.h> |
| 11 | #include <asm/msr.h> |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 12 | |
| 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 | |
| 36 | extern void generic_apic_probe(void); |
| 37 | |
| 38 | #ifdef CONFIG_X86_LOCAL_APIC |
| 39 | |
| 40 | extern int apic_verbosity; |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 41 | extern int local_apic_timer_c2_ok; |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 42 | |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 43 | extern int ioapic_force; |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 44 | |
Yinghai Lu | 3c999f1 | 2008-06-20 16:11:20 -0700 | [diff] [blame] | 45 | extern int disable_apic; |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 46 | /* |
| 47 | * Basic functions accessing APICs. |
| 48 | */ |
| 49 | #ifdef CONFIG_PARAVIRT |
| 50 | #include <asm/paravirt.h> |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 51 | #else |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 52 | #ifndef CONFIG_X86_64 |
| 53 | #define apic_write native_apic_mem_write |
| 54 | #define apic_write_atomic native_apic_mem_write_atomic |
| 55 | #define apic_read native_apic_mem_read |
| 56 | #endif |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 57 | #define setup_boot_clock setup_boot_APIC_clock |
| 58 | #define setup_secondary_clock setup_secondary_APIC_clock |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 59 | #endif |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 60 | |
Ravikiran G Thirumalai | aa7d8e25e | 2008-03-20 00:41:16 -0700 | [diff] [blame] | 61 | extern int is_vsmp_box(void); |
| 62 | |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 63 | static inline void native_apic_mem_write(u32 reg, u32 v) |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 64 | { |
| 65 | *((volatile u32 *)(APIC_BASE + reg)) = v; |
| 66 | } |
| 67 | |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 68 | static inline void native_apic_mem_write_atomic(u32 reg, u32 v) |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 69 | { |
Joe Perches | 3c311fe | 2008-03-23 01:01:40 -0700 | [diff] [blame] | 70 | (void)xchg((u32 *)(APIC_BASE + reg), v); |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 71 | } |
| 72 | |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 73 | static inline u32 native_apic_mem_read(u32 reg) |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 74 | { |
| 75 | return *((volatile u32 *)(APIC_BASE + reg)); |
| 76 | } |
| 77 | |
Suresh Siddha | 13c88fb | 2008-07-10 11:16:52 -0700 | [diff] [blame] | 78 | static inline void native_apic_msr_write(u32 reg, u32 v) |
| 79 | { |
| 80 | if (reg == APIC_DFR || reg == APIC_ID || reg == APIC_LDR || |
| 81 | reg == APIC_LVR) |
| 82 | return; |
| 83 | |
| 84 | wrmsr(APIC_BASE_MSR + (reg >> 4), v, 0); |
| 85 | } |
| 86 | |
| 87 | static inline u32 native_apic_msr_read(u32 reg) |
| 88 | { |
| 89 | u32 low, high; |
| 90 | |
| 91 | if (reg == APIC_DFR) |
| 92 | return -1; |
| 93 | |
| 94 | rdmsr(APIC_BASE_MSR + (reg >> 4), low, high); |
| 95 | return low; |
| 96 | } |
| 97 | |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 98 | #ifdef CONFIG_X86_32 |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 99 | extern void apic_wait_icr_idle(void); |
| 100 | extern u32 safe_apic_wait_icr_idle(void); |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 101 | extern void apic_icr_write(u32 low, u32 id); |
| 102 | #else |
Suresh Siddha | 6e1cb38 | 2008-07-10 11:16:58 -0700 | [diff] [blame^] | 103 | extern int x2apic, x2apic_preenabled; |
| 104 | extern void check_x2apic(void); |
| 105 | extern void enable_x2apic(void); |
| 106 | extern void enable_IR_x2apic(void); |
| 107 | extern void x2apic_icr_write(u32 low, u32 id); |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 108 | |
| 109 | struct apic_ops { |
| 110 | u32 (*read)(u32 reg); |
| 111 | void (*write)(u32 reg, u32 v); |
| 112 | void (*write_atomic)(u32 reg, u32 v); |
| 113 | u64 (*icr_read)(void); |
| 114 | void (*icr_write)(u32 low, u32 high); |
| 115 | void (*wait_icr_idle)(void); |
| 116 | u32 (*safe_wait_icr_idle)(void); |
| 117 | }; |
| 118 | |
| 119 | extern struct apic_ops *apic_ops; |
| 120 | |
| 121 | #define apic_read (apic_ops->read) |
| 122 | #define apic_write (apic_ops->write) |
| 123 | #define apic_write_atomic (apic_ops->write_atomic) |
| 124 | #define apic_icr_read (apic_ops->icr_read) |
| 125 | #define apic_icr_write (apic_ops->icr_write) |
| 126 | #define apic_wait_icr_idle (apic_ops->wait_icr_idle) |
| 127 | #define safe_apic_wait_icr_idle (apic_ops->safe_wait_icr_idle) |
| 128 | #endif |
| 129 | |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 130 | extern int get_physical_broadcast(void); |
| 131 | |
| 132 | #ifdef CONFIG_X86_GOOD_APIC |
| 133 | # define FORCE_READ_AROUND_WRITE 0 |
| 134 | # define apic_read_around(x) |
| 135 | # define apic_write_around(x, y) apic_write((x), (y)) |
| 136 | #else |
| 137 | # define FORCE_READ_AROUND_WRITE 1 |
| 138 | # define apic_read_around(x) apic_read(x) |
| 139 | # define apic_write_around(x, y) apic_write_atomic((x), (y)) |
| 140 | #endif |
| 141 | |
Suresh Siddha | 89027d3 | 2008-07-10 11:16:56 -0700 | [diff] [blame] | 142 | #ifdef CONFIG_X86_64 |
| 143 | static inline void ack_x2APIC_irq(void) |
| 144 | { |
| 145 | /* Docs say use 0 for future compatibility */ |
| 146 | native_apic_msr_write(APIC_EOI, 0); |
| 147 | } |
| 148 | #endif |
| 149 | |
| 150 | |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 151 | static inline void ack_APIC_irq(void) |
| 152 | { |
| 153 | /* |
| 154 | * ack_APIC_irq() actually gets compiled as a single instruction: |
| 155 | * - a single rmw on Pentium/82489DX |
| 156 | * - a single write on P6+ cores (CONFIG_X86_GOOD_APIC) |
| 157 | * ... yummie. |
| 158 | */ |
| 159 | |
| 160 | /* Docs say use 0 for future compatibility */ |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 161 | #ifdef CONFIG_X86_32 |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 162 | apic_write_around(APIC_EOI, 0); |
Suresh Siddha | 1b374e4 | 2008-07-10 11:16:49 -0700 | [diff] [blame] | 163 | #else |
| 164 | native_apic_mem_write(APIC_EOI, 0); |
| 165 | #endif |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 166 | } |
| 167 | |
| 168 | extern int lapic_get_maxlvt(void); |
| 169 | extern void clear_local_APIC(void); |
| 170 | extern void connect_bsp_APIC(void); |
| 171 | extern void disconnect_bsp_APIC(int virt_wire_setup); |
| 172 | extern void disable_local_APIC(void); |
| 173 | extern void lapic_shutdown(void); |
| 174 | extern int verify_local_APIC(void); |
| 175 | extern void cache_APIC_registers(void); |
| 176 | extern void sync_Arb_IDs(void); |
| 177 | extern void init_bsp_APIC(void); |
| 178 | extern void setup_local_APIC(void); |
Andi Kleen | 739f33b | 2008-01-30 13:30:40 +0100 | [diff] [blame] | 179 | extern void end_local_APIC_setup(void); |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 180 | extern void init_apic_mappings(void); |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 181 | extern void setup_boot_APIC_clock(void); |
| 182 | extern void setup_secondary_APIC_clock(void); |
| 183 | extern int APIC_init_uniprocessor(void); |
Jan Beulich | e942710 | 2008-01-30 13:31:24 +0100 | [diff] [blame] | 184 | extern void enable_NMI_through_LVT0(void); |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 185 | |
| 186 | /* |
| 187 | * On 32bit this is mach-xxx local |
| 188 | */ |
| 189 | #ifdef CONFIG_X86_64 |
Yinghai Lu | 8643f9d | 2008-02-19 03:21:06 -0800 | [diff] [blame] | 190 | extern void early_init_lapic_mapping(void); |
Alok Kataria | 8fbbc4b | 2008-07-01 11:43:34 -0700 | [diff] [blame] | 191 | extern int apic_is_clustered_box(void); |
| 192 | #else |
| 193 | static inline int apic_is_clustered_box(void) |
| 194 | { |
| 195 | return 0; |
| 196 | } |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 197 | #endif |
| 198 | |
Robert Richter | 7b83dae | 2008-01-30 13:30:40 +0100 | [diff] [blame] | 199 | extern u8 setup_APIC_eilvt_mce(u8 vector, u8 msg_type, u8 mask); |
| 200 | extern u8 setup_APIC_eilvt_ibs(u8 vector, u8 msg_type, u8 mask); |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 201 | |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 202 | |
| 203 | #else /* !CONFIG_X86_LOCAL_APIC */ |
| 204 | static inline void lapic_shutdown(void) { } |
| 205 | #define local_apic_timer_c2_ok 1 |
Yinghai Lu | f3294a3 | 2008-06-27 01:41:56 -0700 | [diff] [blame] | 206 | static inline void init_apic_mappings(void) { } |
Thomas Gleixner | 67c5fc5 | 2008-01-30 13:30:15 +0100 | [diff] [blame] | 207 | |
| 208 | #endif /* !CONFIG_X86_LOCAL_APIC */ |
| 209 | |
| 210 | #endif /* __ASM_APIC_H */ |