1 #ifndef __ASM_ES7000_APIC_H
2 #define __ASM_ES7000_APIC_H
4 #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu)
5 #define esr_disable (1)
7 static inline int apic_id_registered(void)
12 static inline cpumask_t target_cpus_cluster(void)
17 static inline cpumask_t target_cpus(void)
19 return cpumask_of_cpu(smp_processor_id());
22 #define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER)
23 #define INT_DELIVERY_MODE_CLUSTER (dest_LowestPrio)
24 #define INT_DEST_MODE_CLUSTER (1) /* logical delivery broadcast to all procs */
25 #define NO_BALANCE_IRQ_CLUSTER (1)
27 #define APIC_DFR_VALUE (APIC_DFR_FLAT)
28 #define INT_DELIVERY_MODE (dest_Fixed)
29 #define INT_DEST_MODE (0) /* phys delivery to target procs */
30 #define NO_BALANCE_IRQ (0)
31 #undef APIC_DEST_LOGICAL
32 #define APIC_DEST_LOGICAL 0x0
34 static inline unsigned long check_apicid_used(physid_mask_t bitmap, int apicid)
38 static inline unsigned long check_apicid_present(int bit)
40 return physid_isset(bit, phys_cpu_present_map);
43 #define apicid_cluster(apicid) (apicid & 0xF0)
45 static inline unsigned long calculate_ldr(int cpu)
48 id = xapic_phys_to_log_apicid(cpu);
49 return (SET_APIC_LOGICAL_ID(id));
53 * Set up the logical destination ID.
55 * Intel recommends to set DFR, LdR and TPR before enabling
56 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
57 * document number 292116). So here it goes...
59 static inline void init_apic_ldr_cluster(void)
62 int cpu = smp_processor_id();
64 apic_write(APIC_DFR, APIC_DFR_VALUE_CLUSTER);
65 val = calculate_ldr(cpu);
66 apic_write(APIC_LDR, val);
69 static inline void init_apic_ldr(void)
72 int cpu = smp_processor_id();
74 apic_write(APIC_DFR, APIC_DFR_VALUE);
75 val = calculate_ldr(cpu);
76 apic_write(APIC_LDR, val);
79 extern int apic_version [MAX_APICS];
80 static inline void setup_apic_routing(void)
82 int apic = per_cpu(x86_bios_cpu_apicid, smp_processor_id());
83 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",
84 (apic_version[apic] == 0x14) ?
85 "Physical Cluster" : "Logical Cluster", nr_ioapics, cpus_addr(target_cpus())[0]);
88 static inline int multi_timer_check(int apic, int irq)
93 static inline int apicid_to_node(int logical_apicid)
99 static inline int cpu_present_to_apicid(int mps_cpu)
102 return boot_cpu_physical_apicid;
103 else if (mps_cpu < NR_CPUS)
104 return (int) per_cpu(x86_bios_cpu_apicid, mps_cpu);
109 static inline physid_mask_t apicid_to_cpu_present(int phys_apicid)
113 mask = physid_mask_of_physid(id);
118 extern u8 cpu_2_logical_apicid[];
119 /* Mapping from cpu number to logical apicid */
120 static inline int cpu_to_logical_apicid(int cpu)
125 return (int)cpu_2_logical_apicid[cpu];
127 return logical_smp_processor_id();
131 static inline physid_mask_t ioapic_phys_id_map(physid_mask_t phys_map)
133 /* For clustered we don't have a good way to do this yet - hack */
134 return physids_promote(0xff);
138 static inline void setup_portio_remap(void)
142 extern unsigned int boot_cpu_physical_apicid;
143 static inline int check_phys_apicid_present(int cpu_physical_apicid)
145 boot_cpu_physical_apicid = read_apic_id();
149 static inline unsigned int cpu_mask_to_apicid_cluster(cpumask_t cpumask)
156 num_bits_set = cpus_weight(cpumask);
157 /* Return id to all */
158 if (num_bits_set == NR_CPUS)
161 * The cpus in the mask must all be on the apic cluster. If are not
162 * on the same apicid cluster return default value of TARGET_CPUS.
164 cpu = first_cpu(cpumask);
165 apicid = cpu_to_logical_apicid(cpu);
166 while (cpus_found < num_bits_set) {
167 if (cpu_isset(cpu, cpumask)) {
168 int new_apicid = cpu_to_logical_apicid(cpu);
169 if (apicid_cluster(apicid) !=
170 apicid_cluster(new_apicid)){
171 printk ("%s: Not a valid mask!\n", __func__);
182 static inline unsigned int cpu_mask_to_apicid(cpumask_t cpumask)
189 num_bits_set = cpus_weight(cpumask);
190 /* Return id to all */
191 if (num_bits_set == NR_CPUS)
192 return cpu_to_logical_apicid(0);
194 * The cpus in the mask must all be on the apic cluster. If are not
195 * on the same apicid cluster return default value of TARGET_CPUS.
197 cpu = first_cpu(cpumask);
198 apicid = cpu_to_logical_apicid(cpu);
199 while (cpus_found < num_bits_set) {
200 if (cpu_isset(cpu, cpumask)) {
201 int new_apicid = cpu_to_logical_apicid(cpu);
202 if (apicid_cluster(apicid) !=
203 apicid_cluster(new_apicid)){
204 printk ("%s: Not a valid mask!\n", __func__);
205 return cpu_to_logical_apicid(0);
215 static inline u32 phys_pkg_id(u32 cpuid_apic, int index_msb)
217 return cpuid_apic >> index_msb;
220 #endif /* __ASM_ES7000_APIC_H */