1 #ifndef _ASM_X86_MACH_DEFAULT_MACH_APIC_H
2 #define _ASM_X86_MACH_DEFAULT_MACH_APIC_H
4 #ifdef CONFIG_X86_LOCAL_APIC
6 #include <mach_apicdef.h>
9 #define APIC_DFR_VALUE (APIC_DFR_FLAT)
11 static inline const struct cpumask *default_target_cpus(void)
14 return cpu_online_mask;
21 #include <asm/genapic.h>
22 #define read_apic_id() (apic->get_apic_id(apic_read(APIC_ID)))
23 #define wakeup_secondary_cpu (apic->wakeup_cpu)
24 extern void default_setup_apic_routing(void);
26 #define wakeup_secondary_cpu wakeup_secondary_cpu_via_init
28 * Set up the logical destination ID.
30 * Intel recommends to set DFR, LDR and TPR before enabling
31 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
32 * document number 292116). So here it goes...
34 static inline void default_init_apic_ldr(void)
38 apic_write(APIC_DFR, APIC_DFR_VALUE);
39 val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
40 val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
41 apic_write(APIC_LDR, val);
44 static inline int default_apic_id_registered(void)
46 return physid_isset(read_apic_id(), phys_cpu_present_map);
49 static inline unsigned int
50 default_cpu_mask_to_apicid(const struct cpumask *cpumask)
52 return cpumask_bits(cpumask)[0];
55 static inline unsigned int
56 default_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
57 const struct cpumask *andmask)
59 unsigned long mask1 = cpumask_bits(cpumask)[0];
60 unsigned long mask2 = cpumask_bits(andmask)[0];
61 unsigned long mask3 = cpumask_bits(cpu_online_mask)[0];
63 return (unsigned int)(mask1 & mask2 & mask3);
66 static inline int default_phys_pkg_id(int cpuid_apic, int index_msb)
68 return cpuid_apic >> index_msb;
71 static inline void default_setup_apic_routing(void)
73 #ifdef CONFIG_X86_IO_APIC
74 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
79 static inline int default_apicid_to_node(int logical_apicid)
82 return apicid_2_node[hard_smp_processor_id()];
90 static inline unsigned long default_check_apicid_used(physid_mask_t bitmap, int apicid)
92 return physid_isset(apicid, bitmap);
95 static inline unsigned long default_check_apicid_present(int bit)
97 return physid_isset(bit, phys_cpu_present_map);
100 static inline physid_mask_t default_ioapic_phys_id_map(physid_mask_t phys_map)
105 /* Mapping from cpu number to logical apicid */
106 static inline int default_cpu_to_logical_apicid(int cpu)
111 static inline int __default_cpu_present_to_apicid(int mps_cpu)
113 if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
114 return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu);
120 __default_check_phys_apicid_present(int boot_cpu_physical_apicid)
122 return physid_isset(boot_cpu_physical_apicid, phys_cpu_present_map);
126 static inline int default_cpu_present_to_apicid(int mps_cpu)
128 return __default_cpu_present_to_apicid(mps_cpu);
132 default_check_phys_apicid_present(int boot_cpu_physical_apicid)
134 return __default_check_phys_apicid_present(boot_cpu_physical_apicid);
137 extern int default_cpu_present_to_apicid(int mps_cpu);
138 extern int default_check_phys_apicid_present(int boot_cpu_physical_apicid);
141 static inline physid_mask_t default_apicid_to_cpu_present(int phys_apicid)
143 return physid_mask_of_physid(phys_apicid);
146 #endif /* CONFIG_X86_LOCAL_APIC */
147 #endif /* _ASM_X86_MACH_DEFAULT_MACH_APIC_H */