xref: /openbmc/linux/arch/x86/kernel/apic/apic_common.c (revision d23c977f)
164063505SThomas Gleixner /*
264063505SThomas Gleixner  * Common functions shared between the various APIC flavours
364063505SThomas Gleixner  *
464063505SThomas Gleixner  * SPDX-License-Identifier: GPL-2.0
564063505SThomas Gleixner  */
664063505SThomas Gleixner #include <linux/irq.h>
764063505SThomas Gleixner #include <asm/apic.h>
864063505SThomas Gleixner 
99f9e3bb1SThomas Gleixner u32 apic_default_calc_apicid(unsigned int cpu)
109f9e3bb1SThomas Gleixner {
119f9e3bb1SThomas Gleixner 	return per_cpu(x86_cpu_to_apicid, cpu);
129f9e3bb1SThomas Gleixner }
139f9e3bb1SThomas Gleixner 
149f9e3bb1SThomas Gleixner u32 apic_flat_calc_apicid(unsigned int cpu)
159f9e3bb1SThomas Gleixner {
169f9e3bb1SThomas Gleixner 	return 1U << cpu;
179f9e3bb1SThomas Gleixner }
189f9e3bb1SThomas Gleixner 
1983a10522SThomas Gleixner bool default_check_apicid_used(physid_mask_t *map, int apicid)
2083a10522SThomas Gleixner {
2183a10522SThomas Gleixner 	return physid_isset(apicid, *map);
2283a10522SThomas Gleixner }
2383a10522SThomas Gleixner 
2483a10522SThomas Gleixner void default_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap)
2583a10522SThomas Gleixner {
2683a10522SThomas Gleixner 	*retmap = *phys_map;
2783a10522SThomas Gleixner }
2883a10522SThomas Gleixner 
2964063505SThomas Gleixner int default_cpu_present_to_apicid(int mps_cpu)
3064063505SThomas Gleixner {
3164063505SThomas Gleixner 	if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
32*d23c977fSThomas Gleixner 		return (int)per_cpu(x86_cpu_to_apicid, mps_cpu);
3364063505SThomas Gleixner 	else
3464063505SThomas Gleixner 		return BAD_APICID;
3564063505SThomas Gleixner }
3683a10522SThomas Gleixner EXPORT_SYMBOL_GPL(default_cpu_present_to_apicid);
3764063505SThomas Gleixner 
3864063505SThomas Gleixner int default_check_phys_apicid_present(int phys_apicid)
3964063505SThomas Gleixner {
4064063505SThomas Gleixner 	return physid_isset(phys_apicid, phys_cpu_present_map);
4164063505SThomas Gleixner }
4283a10522SThomas Gleixner 
43a774635dSLi RongQing int default_apic_id_valid(u32 apicid)
4483a10522SThomas Gleixner {
4583a10522SThomas Gleixner 	return (apicid < 255);
4683a10522SThomas Gleixner }
47