blob: 339f4f3feee585b446e534534ac3f7498e71b22c [file] [log] [blame]
Glauber Costa82023502008-03-03 14:12:53 -03001#include <linux/cpumask.h>
2#include <linux/interrupt.h>
3#include <linux/init.h>
4
5#include <linux/mm.h>
6#include <linux/delay.h>
7#include <linux/spinlock.h>
8#include <linux/kernel_stat.h>
9#include <linux/mc146818rtc.h>
10#include <linux/cache.h>
Glauber Costa82023502008-03-03 14:12:53 -030011#include <linux/cpu.h>
12#include <linux/module.h>
13
14#include <asm/smp.h>
15#include <asm/mtrr.h>
16#include <asm/tlbflush.h>
17#include <asm/mmu_context.h>
18#include <asm/apic.h>
19#include <asm/proto.h>
Yinghai Lu43f39892009-01-29 19:31:49 -080020#include <asm/ipi.h>
Glauber Costa82023502008-03-03 14:12:53 -030021
22#ifdef CONFIG_X86_32
Glauber Costa82023502008-03-03 14:12:53 -030023
Ingo Molnardac5f412009-01-28 15:42:24 +010024void default_send_IPI_self(int vector)
Glauber Costa82023502008-03-03 14:12:53 -030025{
Yinghai Lu43f39892009-01-29 19:31:49 -080026 __default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical);
Glauber Costa82023502008-03-03 14:12:53 -030027}
28
29/* must come after the send_IPI functions above for inlining */
Glauber Costa82023502008-03-03 14:12:53 -030030static int convert_apicid_to_cpu(int apic_id)
31{
32 int i;
33
34 for_each_possible_cpu(i) {
35 if (per_cpu(x86_cpu_to_apicid, i) == apic_id)
36 return i;
37 }
38 return -1;
39}
40
41int safe_smp_processor_id(void)
42{
43 int apicid, cpuid;
44
45 if (!boot_cpu_has(X86_FEATURE_APIC))
46 return 0;
47
48 apicid = hard_smp_processor_id();
49 if (apicid == BAD_APICID)
50 return 0;
51
52 cpuid = convert_apicid_to_cpu(apicid);
53
54 return cpuid >= 0 ? cpuid : 0;
55}
56#endif