Glauber Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 1 | #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 Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 11 | #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 Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame^] | 20 | #include <asm/ipi.h> |
Glauber Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 21 | |
| 22 | #ifdef CONFIG_X86_32 |
Glauber Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 23 | |
Ingo Molnar | dac5f41 | 2009-01-28 15:42:24 +0100 | [diff] [blame] | 24 | void default_send_IPI_self(int vector) |
Glauber Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 25 | { |
Yinghai Lu | 43f3989 | 2009-01-29 19:31:49 -0800 | [diff] [blame^] | 26 | __default_send_IPI_shortcut(APIC_DEST_SELF, vector, apic->dest_logical); |
Glauber Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | /* must come after the send_IPI functions above for inlining */ |
Glauber Costa | 8202350 | 2008-03-03 14:12:53 -0300 | [diff] [blame] | 30 | static 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 | |
| 41 | int 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 |