Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
torvalds
GitHub Repository: torvalds/linux
Path: blob/master/arch/x86/kernel/apic/apic_common.c
48905 views
1
/*
2
* Common functions shared between the various APIC flavours
3
*
4
* SPDX-License-Identifier: GPL-2.0
5
*/
6
#include <linux/irq.h>
7
#include <linux/kvm_types.h>
8
#include <asm/apic.h>
9
10
#include "local.h"
11
12
u32 apic_default_calc_apicid(unsigned int cpu)
13
{
14
return per_cpu(x86_cpu_to_apicid, cpu);
15
}
16
17
u32 apic_flat_calc_apicid(unsigned int cpu)
18
{
19
return 1U << cpu;
20
}
21
22
u32 default_cpu_present_to_apicid(int mps_cpu)
23
{
24
if (mps_cpu < nr_cpu_ids && cpu_present(mps_cpu))
25
return (int)per_cpu(x86_cpu_to_apicid, mps_cpu);
26
else
27
return BAD_APICID;
28
}
29
EXPORT_SYMBOL_FOR_KVM(default_cpu_present_to_apicid);
30
31
/*
32
* Set up the logical destination ID when the APIC operates in logical
33
* destination mode.
34
*/
35
void default_init_apic_ldr(void)
36
{
37
unsigned long val;
38
39
apic_write(APIC_DFR, APIC_DFR_FLAT);
40
val = apic_read(APIC_LDR) & ~APIC_LDR_MASK;
41
val |= SET_APIC_LOGICAL_ID(1UL << smp_processor_id());
42
apic_write(APIC_LDR, val);
43
}
44
45