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 | */ |
Glauber Costa | c1fa6c9 | 2008-03-27 14:05:59 -0300 | [diff] [blame^] | 10 | #ifdef CONFIG_X86_LOCAL_APIC |
| 11 | # include <asm/mpspec.h> |
| 12 | # include <asm/apic.h> |
| 13 | # ifdef CONFIG_X86_IO_APIC |
| 14 | # include <asm/io_apic.h> |
| 15 | # endif |
| 16 | #endif |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 17 | #include <asm/pda.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 18 | #include <asm/thread_info.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Andi Kleen | 3c02175 | 2006-01-11 22:45:12 +0100 | [diff] [blame] | 20 | extern cpumask_t cpu_initialized; |
Glauber Costa | a355352 | 2008-03-03 14:12:58 -0300 | [diff] [blame] | 21 | extern cpumask_t cpu_callin_map; |
Andi Kleen | a8ab26f | 2005-04-16 15:25:19 -0700 | [diff] [blame] | 22 | |
Laurent Vivier | 66d16ed | 2007-10-19 20:35:03 +0200 | [diff] [blame] | 23 | extern int smp_call_function_mask(cpumask_t mask, void (*func)(void *), |
| 24 | void *info, int wait); |
Eric W. Biederman | 3d483f4 | 2005-07-29 14:03:29 -0700 | [diff] [blame] | 25 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 26 | #ifdef CONFIG_SMP |
| 27 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 28 | #define raw_smp_processor_id() read_pda(cpunumber) |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 29 | |
| 30 | #define stack_smp_processor_id() \ |
Joe Perches | ceb7ce1 | 2008-03-23 01:03:30 -0700 | [diff] [blame] | 31 | ({ \ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 32 | struct thread_info *ti; \ |
Joe Perches | ceb7ce1 | 2008-03-23 01:03:30 -0700 | [diff] [blame] | 33 | asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 34 | ti->cpu; \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | }) |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * On x86 all CPUs are mapped 1:1 to the APIC space. This simplifies |
| 39 | * scheduling and IPI sending and compresses data structures. |
| 40 | */ |
| 41 | static inline int num_booting_cpus(void) |
| 42 | { |
| 43 | return cpus_weight(cpu_callout_map); |
| 44 | } |
| 45 | |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 46 | #else /* CONFIG_SMP */ |
Thomas Gleixner | ae9d983 | 2008-01-30 13:30:36 +0100 | [diff] [blame] | 47 | #define stack_smp_processor_id() 0 |
| 48 | |
| 49 | #endif /* !CONFIG_SMP */ |
| 50 | |
| 51 | #define safe_smp_processor_id() smp_processor_id() |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | #endif |
| 54 | |