Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_MACH_APIC_H |
| 2 | #define __ASM_MACH_APIC_H |
| 3 | |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 4 | #ifdef CONFIG_X86_LOCAL_APIC |
| 5 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | #include <mach_apicdef.h> |
| 7 | #include <asm/smp.h> |
| 8 | |
| 9 | #define APIC_DFR_VALUE (APIC_DFR_FLAT) |
| 10 | |
| 11 | static inline cpumask_t target_cpus(void) |
| 12 | { |
| 13 | #ifdef CONFIG_SMP |
| 14 | return cpu_online_map; |
| 15 | #else |
| 16 | return cpumask_of_cpu(0); |
| 17 | #endif |
| 18 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
| 20 | #define NO_BALANCE_IRQ (0) |
| 21 | #define esr_disable (0) |
| 22 | |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 23 | #ifdef CONFIG_X86_64 |
| 24 | #include <asm/genapic.h> |
| 25 | #define INT_DELIVERY_MODE (genapic->int_delivery_mode) |
| 26 | #define INT_DEST_MODE (genapic->int_dest_mode) |
| 27 | #define TARGET_CPUS (genapic->target_cpus()) |
| 28 | #define apic_id_registered (genapic->apic_id_registered) |
| 29 | #define init_apic_ldr (genapic->init_apic_ldr) |
| 30 | #define cpu_mask_to_apicid (genapic->cpu_mask_to_apicid) |
| 31 | #define phys_pkg_id (genapic->phys_pkg_id) |
| 32 | #define vector_allocation_domain (genapic->vector_allocation_domain) |
| 33 | extern void setup_apic_routing(void); |
| 34 | #else |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | #define INT_DELIVERY_MODE dest_LowestPrio |
| 36 | #define INT_DEST_MODE 1 /* logical delivery broadcast to all procs */ |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 37 | #define TARGET_CPUS (target_cpus()) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | /* |
| 39 | * Set up the logical destination ID. |
| 40 | * |
| 41 | * Intel recommends to set DFR, LDR and TPR before enabling |
| 42 | * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel |
| 43 | * document number 292116). So here it goes... |
| 44 | */ |
| 45 | static inline void init_apic_ldr(void) |
| 46 | { |
| 47 | unsigned long val; |
| 48 | |
| 49 | apic_write_around(APIC_DFR, APIC_DFR_VALUE); |
| 50 | val = apic_read(APIC_LDR) & ~APIC_LDR_MASK; |
| 51 | val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id()); |
| 52 | apic_write_around(APIC_LDR, val); |
| 53 | } |
| 54 | |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 55 | static inline int apic_id_registered(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | { |
Jack Steiner | 05f2d12 | 2008-03-28 14:12:02 -0500 | [diff] [blame] | 57 | return physid_isset(GET_APIC_ID(read_apic_id()), phys_cpu_present_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | } |
| 59 | |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 60 | static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask) |
| 61 | { |
| 62 | return cpus_addr(cpumask)[0]; |
| 63 | } |
| 64 | |
| 65 | static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb) |
| 66 | { |
| 67 | return cpuid_apic >> index_msb; |
| 68 | } |
| 69 | |
Ingo Molnar | 3c43f03 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 70 | static inline void setup_apic_routing(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | { |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 72 | #ifdef CONFIG_X86_IO_APIC |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | printk("Enabling APIC mode: %s. Using %d I/O APICs\n", |
| 74 | "Flat", nr_ioapics); |
Alexey Starikovskiy | 61048c6 | 2008-04-04 23:41:07 +0400 | [diff] [blame] | 75 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 78 | static inline int apicid_to_node(int logical_apicid) |
| 79 | { |
| 80 | return 0; |
| 81 | } |
Glauber de Oliveira Costa | f6bc402 | 2008-03-19 14:25:53 -0300 | [diff] [blame] | 82 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 84 | static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid) |
| 85 | { |
| 86 | return physid_isset(apicid, bitmap); |
| 87 | } |
| 88 | |
| 89 | static inline unsigned long check_apicid_present(int bit) |
| 90 | { |
| 91 | return physid_isset(bit, phys_cpu_present_map); |
| 92 | } |
| 93 | |
| 94 | static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map) |
| 95 | { |
| 96 | return phys_map; |
| 97 | } |
| 98 | |
| 99 | static inline int multi_timer_check(int apic, int irq) |
| 100 | { |
| 101 | return 0; |
| 102 | } |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | /* Mapping from cpu number to logical apicid */ |
| 105 | static inline int cpu_to_logical_apicid(int cpu) |
| 106 | { |
| 107 | return 1 << cpu; |
| 108 | } |
| 109 | |
| 110 | static inline int cpu_present_to_apicid(int mps_cpu) |
| 111 | { |
Hugh Dickins | 5f46470 | 2008-04-30 16:17:46 +0100 | [diff] [blame] | 112 | if (mps_cpu < NR_CPUS && cpu_present(mps_cpu)) |
Glauber de Oliveira Costa | f6bc402 | 2008-03-19 14:25:53 -0300 | [diff] [blame] | 113 | return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 114 | else |
| 115 | return BAD_APICID; |
| 116 | } |
| 117 | |
| 118 | static inline physid_mask_t apicid_to_cpu_present(int phys_apicid) |
| 119 | { |
| 120 | return physid_mask_of_physid(phys_apicid); |
| 121 | } |
| 122 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 123 | static inline void setup_portio_remap(void) |
| 124 | { |
| 125 | } |
| 126 | |
| 127 | static inline int check_phys_apicid_present(int boot_cpu_physical_apicid) |
| 128 | { |
| 129 | return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map); |
| 130 | } |
| 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | static inline void enable_apic_mode(void) |
| 133 | { |
| 134 | } |
| 135 | |
Glauber Costa | dd46e3c | 2008-03-25 18:10:46 -0300 | [diff] [blame] | 136 | #endif /* CONFIG_X86_LOCAL_APIC */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | #endif /* __ASM_MACH_APIC_H */ |