Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __ASM_SMP_H |
| 2 | #define __ASM_SMP_H |
| 3 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 4 | #include <linux/cpumask.h> |
| 5 | #include <linux/init.h> |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | /* |
| 8 | * We need the APIC definitions automatically as part of 'smp.h' |
| 9 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | #include <asm/apic.h> |
Jan Beulich | 00f1ea6 | 2007-05-02 19:27:04 +0200 | [diff] [blame] | 11 | #include <asm/io_apic.h> |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 12 | #include <asm/mpspec.h> |
| 13 | #include <asm/pda.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 14 | #include <asm/thread_info.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 15 | |
Andi Kleen | 3c02175 | 2006-01-11 22:45:12 +0100 | [diff] [blame] | 16 | extern cpumask_t cpu_initialized; |
Andi Kleen | a8ab26f | 2005-04-16 15:25:19 -0700 | [diff] [blame] | 17 | |
Laurent Vivier | 66d16ed | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 18 | extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *), |
| 19 | void *info, int wait); |
Eric W. Biederman | 3d483f4 | 2005-07-29 14:03:29 -0700 | [diff] [blame] | 20 | |
travis@sgi.com | ef97001 | 2008-01-30 13:33:10 +0100 | [diff] [blame] | 21 | extern u16 __initdata x86_cpu_to_apicid_init[]; |
travis@sgi.com | e8c10ef | 2008-01-30 13:33:12 +0100 | [diff] [blame] | 22 | extern u16 __initdata x86_bios_cpu_apicid_init[]; |
travis@sgi.com | 3b41908 | 2008-01-30 13:33:11 +0100 | [diff] [blame] | 23 | extern void *x86_cpu_to_apicid_early_ptr; |
travis@sgi.com | e8c10ef | 2008-01-30 13:33:12 +0100 | [diff] [blame] | 24 | extern void *x86_bios_cpu_apicid_early_ptr; |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 25 | |
Mike Travis | d5a7430 | 2007-10-16 01:24:05 -0700 | [diff] [blame] | 26 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); |
Mike Travis | 0835761 | 2007-10-16 01:24:04 -0700 | [diff] [blame] | 27 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); |
travis@sgi.com | ef97001 | 2008-01-30 13:33:10 +0100 | [diff] [blame] | 28 | DECLARE_PER_CPU(u16, cpu_llc_id); |
| 29 | DECLARE_PER_CPU(u16, x86_cpu_to_apicid); |
travis@sgi.com | e8c10ef | 2008-01-30 13:33:12 +0100 | [diff] [blame] | 30 | DECLARE_PER_CPU(u16, x86_bios_cpu_apicid); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | static inline int cpu_present_to_apicid(int mps_cpu) |
| 33 | { |
travis@sgi.com | e8c10ef | 2008-01-30 13:33:12 +0100 | [diff] [blame] | 34 | if (cpu_present(mps_cpu)) |
| 35 | return (int)per_cpu(x86_bios_cpu_apicid, mps_cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | else |
| 37 | return BAD_APICID; |
| 38 | } |
| 39 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 40 | #ifdef CONFIG_SMP |
| 41 | |
| 42 | #define SMP_TRAMPOLINE_BASE 0x6000 |
| 43 | |
| 44 | extern int __cpu_disable(void); |
| 45 | extern void __cpu_die(unsigned int cpu); |
| 46 | extern void prefill_possible_map(void); |
| 47 | extern unsigned __cpuinitdata disabled_cpus; |
| 48 | |
| 49 | #define raw_smp_processor_id() read_pda(cpunumber) |
| 50 | #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) |
| 51 | |
| 52 | #define stack_smp_processor_id() \ |
| 53 | ({ \ |
| 54 | struct thread_info *ti; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 56 | ti->cpu; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | }) |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 58 | |
| 59 | /* |
| 60 | * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies |
| 61 | * scheduling and IPI sending and compresses data structures. |
| 62 | */ |
| 63 | static inline int num_booting_cpus(void) |
| 64 | { |
| 65 | return cpus_weight(cpu_callout_map); |
| 66 | } |
| 67 | |
| 68 | extern void smp_send_reschedule(int cpu); |
| 69 | |
| 70 | #else /* CONFIG_SMP */ |
| 71 | |
| 72 | extern unsigned int boot_cpu_id; |
| 73 | #define cpu_physical_id(cpu) boot_cpu_id |
| 74 | #define stack_smp_processor_id() 0 |
| 75 | |
| 76 | #endif /* !CONFIG_SMP */ |
| 77 | |
| 78 | #define safe_smp_processor_id() smp_processor_id() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | static __inline int logical_smp_processor_id(void) |
| 81 | { |
| 82 | /* we don't want to mark this access volatile - bad code generation */ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 83 | return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 84 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 86 | static inline int hard_smp_processor_id(void) |
| 87 | { |
| 88 | /* we don't want to mark this access volatile - bad code generation */ |
| 89 | return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID)); |
| 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | #endif |
| 93 | |