2005-04-16 15:20:36 -07:00
# ifndef __ASM_SMP_H
# define __ASM_SMP_H
# include <linux/cpumask.h>
2007-03-16 21:07:36 +01:00
# include <linux/init.h>
2005-04-16 15:20:36 -07:00
2008-01-30 13:30:36 +01:00
/*
* We need the APIC definitions automatically as part of ' smp . h '
*/
2005-04-16 15:20:36 -07:00
# include <asm/apic.h>
2007-05-02 19:27:04 +02:00
# include <asm/io_apic.h>
2008-01-30 13:30:36 +01:00
# include <asm/mpspec.h>
2005-04-16 15:20:36 -07:00
# include <asm/pda.h>
2008-01-30 13:30:36 +01:00
# include <asm/thread_info.h>
2005-04-16 15:20:36 -07:00
2006-01-11 22:45:12 +01:00
extern cpumask_t cpu_initialized ;
2008-03-03 14:12:58 -03:00
extern cpumask_t cpu_callin_map ;
2005-04-16 15:25:19 -07:00
2007-10-19 20:35:03 +02:00
extern int smp_call_function_mask ( cpumask_t mask , void ( * func ) ( void * ) ,
void * info , int wait ) ;
2005-07-29 14:03:29 -07:00
2008-01-30 13:30:36 +01:00
# ifdef CONFIG_SMP
# define raw_smp_processor_id() read_pda(cpunumber)
2007-10-19 18:23:02 -07:00
2008-01-30 13:30:36 +01:00
# define stack_smp_processor_id() \
( { \
struct thread_info * ti ; \
__asm__ ( " andq %%rsp,%0; " : " =r " ( ti ) : " 0 " ( CURRENT_MASK ) ) ; \
ti - > cpu ; \
} )
2007-05-09 02:33:28 -07:00
2005-04-16 15:20:36 -07:00
/*
2008-01-30 13:30:36 +01:00
* On x86 all CPUs are mapped 1 : 1 to the APIC space . This simplifies
* scheduling and IPI sending and compresses data structures .
2005-04-16 15:20:36 -07:00
*/
2008-01-30 13:30:36 +01:00
static inline int num_booting_cpus ( void )
2005-04-16 15:20:36 -07:00
{
2008-01-30 13:30:36 +01:00
return cpus_weight ( cpu_callout_map ) ;
2005-04-16 15:20:36 -07:00
}
2008-01-30 13:30:36 +01:00
# else /* CONFIG_SMP */
2005-04-16 15:20:36 -07:00
# define stack_smp_processor_id() 0
2008-01-30 13:30:36 +01:00
# endif /* !CONFIG_SMP */
# define safe_smp_processor_id() smp_processor_id()
2005-04-16 15:20:36 -07:00
static __inline int logical_smp_processor_id ( void )
{
/* we don't want to mark this access volatile - bad code generation */
2008-01-30 13:30:36 +01:00
return GET_APIC_LOGICAL_ID ( * ( u32 * ) ( APIC_BASE + APIC_LDR ) ) ;
}
2008-03-19 14:25:53 -03:00
# include <mach_apicdef.h>
2008-01-30 13:30:36 +01:00
static inline int hard_smp_processor_id ( void )
{
/* we don't want to mark this access volatile - bad code generation */
return GET_APIC_ID ( * ( u32 * ) ( APIC_BASE + APIC_ID ) ) ;
2005-04-16 15:20:36 -07:00
}
# endif