]>
git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blob - arch/x86/include/asm/es7000/apic.h
847008a77029cd4df4911fe6ed737466335c8661
1 #ifndef __ASM_ES7000_APIC_H
2 #define __ASM_ES7000_APIC_H
6 #define xapic_phys_to_log_apicid(cpu) per_cpu(x86_bios_cpu_apicid, cpu)
8 static inline int es7000_apic_id_registered(void)
13 static inline const cpumask_t
*target_cpus_cluster(void)
18 static inline const cpumask_t
*es7000_target_cpus(void)
20 return &cpumask_of_cpu(smp_processor_id());
23 #define APIC_DFR_VALUE_CLUSTER (APIC_DFR_CLUSTER)
24 #define INT_DELIVERY_MODE_CLUSTER (dest_LowestPrio)
25 #define INT_DEST_MODE_CLUSTER (1) /* logical delivery broadcast to all procs */
27 #define APIC_DFR_VALUE (APIC_DFR_FLAT)
29 static inline unsigned long
30 es7000_check_apicid_used(physid_mask_t bitmap
, int apicid
)
34 static inline unsigned long es7000_check_apicid_present(int bit
)
36 return physid_isset(bit
, phys_cpu_present_map
);
39 #define apicid_cluster(apicid) (apicid & 0xF0)
41 static inline unsigned long calculate_ldr(int cpu
)
44 id
= xapic_phys_to_log_apicid(cpu
);
45 return (SET_APIC_LOGICAL_ID(id
));
49 * Set up the logical destination ID.
51 * Intel recommends to set DFR, LdR and TPR before enabling
52 * an APIC. See e.g. "AP-388 82489DX User's Manual" (Intel
53 * document number 292116). So here it goes...
55 static inline void init_apic_ldr_cluster(void)
58 int cpu
= smp_processor_id();
60 apic_write(APIC_DFR
, APIC_DFR_VALUE_CLUSTER
);
61 val
= calculate_ldr(cpu
);
62 apic_write(APIC_LDR
, val
);
65 static inline void init_apic_ldr(void)
68 int cpu
= smp_processor_id();
70 apic_write(APIC_DFR
, APIC_DFR_VALUE
);
71 val
= calculate_ldr(cpu
);
72 apic_write(APIC_LDR
, val
);
75 extern int apic_version
[MAX_APICS
];
76 static inline void setup_apic_routing(void)
78 int apic
= per_cpu(x86_bios_cpu_apicid
, smp_processor_id());
79 printk("Enabling APIC mode: %s. Using %d I/O APICs, target cpus %lx\n",
80 (apic_version
[apic
] == 0x14) ?
81 "Physical Cluster" : "Logical Cluster",
82 nr_ioapics
, cpus_addr(*es7000_target_cpus())[0]);
85 static inline int multi_timer_check(int apic
, int irq
)
90 static inline int apicid_to_node(int logical_apicid
)
96 static inline int cpu_present_to_apicid(int mps_cpu
)
99 return boot_cpu_physical_apicid
;
100 else if (mps_cpu
< nr_cpu_ids
)
101 return (int) per_cpu(x86_bios_cpu_apicid
, mps_cpu
);
106 static inline physid_mask_t
apicid_to_cpu_present(int phys_apicid
)
110 mask
= physid_mask_of_physid(id
);
115 extern u8 cpu_2_logical_apicid
[];
116 /* Mapping from cpu number to logical apicid */
117 static inline int cpu_to_logical_apicid(int cpu
)
120 if (cpu
>= nr_cpu_ids
)
122 return (int)cpu_2_logical_apicid
[cpu
];
124 return logical_smp_processor_id();
128 static inline physid_mask_t
ioapic_phys_id_map(physid_mask_t phys_map
)
130 /* For clustered we don't have a good way to do this yet - hack */
131 return physids_promote(0xff);
135 static inline void setup_portio_remap(void)
139 extern unsigned int boot_cpu_physical_apicid
;
140 static inline int check_phys_apicid_present(int cpu_physical_apicid
)
142 boot_cpu_physical_apicid
= read_apic_id();
146 static inline unsigned int
147 cpu_mask_to_apicid_cluster(const struct cpumask
*cpumask
)
154 num_bits_set
= cpumask_weight(cpumask
);
155 /* Return id to all */
156 if (num_bits_set
== nr_cpu_ids
)
159 * The cpus in the mask must all be on the apic cluster. If are not
160 * on the same apicid cluster return default value of target_cpus():
162 cpu
= cpumask_first(cpumask
);
163 apicid
= cpu_to_logical_apicid(cpu
);
164 while (cpus_found
< num_bits_set
) {
165 if (cpumask_test_cpu(cpu
, cpumask
)) {
166 int new_apicid
= cpu_to_logical_apicid(cpu
);
167 if (apicid_cluster(apicid
) !=
168 apicid_cluster(new_apicid
)){
169 printk ("%s: Not a valid mask!\n", __func__
);
180 static inline unsigned int cpu_mask_to_apicid(const cpumask_t
*cpumask
)
187 num_bits_set
= cpus_weight(*cpumask
);
188 /* Return id to all */
189 if (num_bits_set
== nr_cpu_ids
)
190 return cpu_to_logical_apicid(0);
192 * The cpus in the mask must all be on the apic cluster. If are not
193 * on the same apicid cluster return default value of target_cpus():
195 cpu
= first_cpu(*cpumask
);
196 apicid
= cpu_to_logical_apicid(cpu
);
197 while (cpus_found
< num_bits_set
) {
198 if (cpu_isset(cpu
, *cpumask
)) {
199 int new_apicid
= cpu_to_logical_apicid(cpu
);
200 if (apicid_cluster(apicid
) !=
201 apicid_cluster(new_apicid
)){
202 printk ("%s: Not a valid mask!\n", __func__
);
203 return cpu_to_logical_apicid(0);
214 static inline unsigned int cpu_mask_to_apicid_and(const struct cpumask
*inmask
,
215 const struct cpumask
*andmask
)
217 int apicid
= cpu_to_logical_apicid(0);
218 cpumask_var_t cpumask
;
220 if (!alloc_cpumask_var(&cpumask
, GFP_ATOMIC
))
223 cpumask_and(cpumask
, inmask
, andmask
);
224 cpumask_and(cpumask
, cpumask
, cpu_online_mask
);
225 apicid
= cpu_mask_to_apicid(cpumask
);
227 free_cpumask_var(cpumask
);
231 static inline u32
phys_pkg_id(u32 cpuid_apic
, int index_msb
)
233 return cpuid_apic
>> index_msb
;
236 #endif /* __ASM_ES7000_APIC_H */