x86, apic: refactor ->cpu_mask_to_apicid*()
[linux-2.6/mini2440.git] / arch / x86 / include / asm / numaq / apic.h
blobce95e79f72338ca07253511f2f944afe84967a72
1 #ifndef __ASM_NUMAQ_APIC_H
2 #define __ASM_NUMAQ_APIC_H
4 #include <asm/io.h>
5 #include <linux/mmzone.h>
6 #include <linux/nodemask.h>
8 #define APIC_DFR_VALUE (APIC_DFR_CLUSTER)
10 static inline const cpumask_t *numaq_target_cpus(void)
12 return &CPU_MASK_ALL;
15 static inline unsigned long
16 numaq_check_apicid_used(physid_mask_t bitmap, int apicid)
18 return physid_isset(apicid, bitmap);
20 static inline unsigned long numaq_check_apicid_present(int bit)
22 return physid_isset(bit, phys_cpu_present_map);
24 #define apicid_cluster(apicid) (apicid & 0xF0)
26 static inline int numaq_apic_id_registered(void)
28 return 1;
31 static inline void numaq_init_apic_ldr(void)
33 /* Already done in NUMA-Q firmware */
36 static inline void numaq_setup_apic_routing(void)
38 printk("Enabling APIC mode: %s. Using %d I/O APICs\n",
39 "NUMA-Q", nr_ioapics);
43 * Skip adding the timer int on secondary nodes, which causes
44 * a small but painful rift in the time-space continuum.
46 static inline int numaq_multi_timer_check(int apic, int irq)
48 return apic != 0 && irq == 0;
51 static inline physid_mask_t numaq_ioapic_phys_id_map(physid_mask_t phys_map)
53 /* We don't have a good way to do this yet - hack */
54 return physids_promote(0xFUL);
57 /* Mapping from cpu number to logical apicid */
58 extern u8 cpu_2_logical_apicid[];
60 static inline int numaq_cpu_to_logical_apicid(int cpu)
62 if (cpu >= nr_cpu_ids)
63 return BAD_APICID;
64 return (int)cpu_2_logical_apicid[cpu];
68 * Supporting over 60 cpus on NUMA-Q requires a locality-dependent
69 * cpu to APIC ID relation to properly interact with the intelligent
70 * mode of the cluster controller.
72 static inline int numaq_cpu_present_to_apicid(int mps_cpu)
74 if (mps_cpu < 60)
75 return ((mps_cpu >> 2) << 4) | (1 << (mps_cpu & 0x3));
76 else
77 return BAD_APICID;
80 static inline int numaq_apicid_to_node(int logical_apicid)
82 return logical_apicid >> 4;
85 static inline physid_mask_t numaq_apicid_to_cpu_present(int logical_apicid)
87 int node = numaq_apicid_to_node(logical_apicid);
88 int cpu = __ffs(logical_apicid & 0xf);
90 return physid_mask_of_physid(cpu + 4*node);
93 extern void *xquad_portio;
95 static inline int numaq_check_phys_apicid_present(int boot_cpu_physical_apicid)
97 return 1;
101 * We use physical apicids here, not logical, so just return the default
102 * physical broadcast to stop people from breaking us
104 static inline unsigned int numaq_cpu_mask_to_apicid(const cpumask_t *cpumask)
106 return 0x0F;
109 static inline unsigned int
110 numaq_cpu_mask_to_apicid_and(const struct cpumask *cpumask,
111 const struct cpumask *andmask)
113 return 0x0F;
116 /* No NUMA-Q box has a HT CPU, but it can't hurt to use the default code. */
117 static inline int numaq_phys_pkg_id(int cpuid_apic, int index_msb)
119 return cpuid_apic >> index_msb;
122 #endif /* __ASM_NUMAQ_APIC_H */