]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/include/asm/bigsmp/apic.h
x86, apic: clean up target_cpus methods
[linux-2.6-omap-h63xx.git] / arch / x86 / include / asm / bigsmp / apic.h
1 #ifndef __ASM_MACH_APIC_H
2 #define __ASM_MACH_APIC_H
3
4 #define xapic_phys_to_log_apicid(cpu) (per_cpu(x86_bios_cpu_apicid, cpu))
5 #define esr_disable (1)
6
7 static inline int bigsmp_apic_id_registered(void)
8 {
9         return 1;
10 }
11
12 static inline const cpumask_t *bigsmp_target_cpus(void)
13 {
14 #ifdef CONFIG_SMP
15         return &cpu_online_map;
16 #else
17         return &cpumask_of_cpu(0);
18 #endif
19 }
20
21 #undef APIC_DEST_LOGICAL
22 #define APIC_DEST_LOGICAL       0
23 #define APIC_DFR_VALUE          (APIC_DFR_FLAT)
24 #define NO_BALANCE_IRQ          (0)
25
26 static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
27 {
28         return (0);
29 }
30
31 static inline unsigned long check_apicid_present(int bit)
32 {
33         return (1);
34 }
35
36 static inline unsigned long calculate_ldr(int cpu)
37 {
38         unsigned long val, id;
39         val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
40         id = xapic_phys_to_log_apicid(cpu);
41         val |= SET_APIC_LOGICAL_ID(id);
42         return val;
43 }
44
45 /*
46  * Set up the logical destination ID.
47  *
48  * Intel recommends to set DFR, LDR and TPR before enabling
49  * an APIC.  See e.g. "AP-388 82489DX User's Manual" (Intel
50  * document number 292116).  So here it goes...
51  */
52 static inline void init_apic_ldr(void)
53 {
54         unsigned long val;
55         int cpu = smp_processor_id();
56
57         apic_write(APIC_DFR, APIC_DFR_VALUE);
58         val = calculate_ldr(cpu);
59         apic_write(APIC_LDR, val);
60 }
61
62 static inline void setup_apic_routing(void)
63 {
64         printk("Enabling APIC mode:  %s.  Using %d I/O APICs\n",
65                 "Physflat", nr_ioapics);
66 }
67
68 static inline int multi_timer_check(int apic, int irq)
69 {
70         return (0);
71 }
72
73 static inline int apicid_to_node(int logical_apicid)
74 {
75         return apicid_2_node[hard_smp_processor_id()];
76 }
77
78 static inline int cpu_present_to_apicid(int mps_cpu)
79 {
80         if (mps_cpu < nr_cpu_ids)
81                 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
82
83         return BAD_APICID;
84 }
85
86 static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
87 {
88         return physid_mask_of_physid(phys_apicid);
89 }
90
91 extern u8 cpu_2_logical_apicid[];
92 /* Mapping from cpu number to logical apicid */
93 static inline int cpu_to_logical_apicid(int cpu)
94 {
95         if (cpu >= nr_cpu_ids)
96                 return BAD_APICID;
97         return cpu_physical_id(cpu);
98 }
99
100 static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
101 {
102         /* For clustered we don't have a good way to do this yet - hack */
103         return physids_promote(0xFFL);
104 }
105
106 static inline void setup_portio_remap(void)
107 {
108 }
109
110 static inline void enable_apic_mode(void)
111 {
112 }
113
114 static inline int check_phys_apicid_present(int boot_cpu_physical_apicid)
115 {
116         return (1);
117 }
118
119 /* As we are using single CPU as destination, pick only one CPU here */
120 static inline unsigned int cpu_mask_to_apicid(const cpumask_t *cpumask)
121 {
122         int cpu;
123         int apicid;     
124
125         cpu = first_cpu(*cpumask);
126         apicid = cpu_to_logical_apicid(cpu);
127         return apicid;
128 }
129
130 static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask *cpumask,
131                                                   const struct cpumask *andmask)
132 {
133         int cpu;
134
135         /*
136          * We're using fixed IRQ delivery, can only return one phys APIC ID.
137          * May as well be the first.
138          */
139         for_each_cpu_and(cpu, cpumask, andmask)
140                 if (cpumask_test_cpu(cpu, cpu_online_mask))
141                         break;
142         if (cpu < nr_cpu_ids)
143                 return cpu_to_logical_apicid(cpu);
144
145         return BAD_APICID;
146 }
147
148 static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
149 {
150         return cpuid_apic >> index_msb;
151 }
152
153 #endif /* __ASM_MACH_APIC_H */