2005-04-16 15:20:36 -07:00
|
|
|
#ifndef __ASM_SMP_H
|
|
|
|
#define __ASM_SMP_H
|
|
|
|
|
|
|
|
#include <linux/cpumask.h>
|
2007-03-16 13:07:36 -07:00
|
|
|
#include <linux/init.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-01-30 05:30:36 -07: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 10:27:04 -07:00
|
|
|
#include <asm/io_apic.h>
|
2008-01-30 05:30:36 -07:00
|
|
|
#include <asm/mpspec.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/pda.h>
|
2008-01-30 05:30:36 -07:00
|
|
|
#include <asm/thread_info.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2006-01-11 14:45:12 -07:00
|
|
|
extern cpumask_t cpu_initialized;
|
2008-03-03 10:12:58 -07:00
|
|
|
extern cpumask_t cpu_callin_map;
|
2005-04-16 15:25:19 -07:00
|
|
|
|
2007-10-19 11:35:03 -07: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 05:30:36 -07:00
|
|
|
#ifdef CONFIG_SMP
|
|
|
|
|
|
|
|
#define raw_smp_processor_id() read_pda(cpunumber)
|
2007-10-19 18:23:02 -07:00
|
|
|
|
2008-01-30 05:30:36 -07:00
|
|
|
#define stack_smp_processor_id() \
|
2008-03-23 01:03:30 -07:00
|
|
|
({ \
|
2008-01-30 05:30:36 -07:00
|
|
|
struct thread_info *ti; \
|
2008-03-23 01:03:30 -07:00
|
|
|
asm("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
|
2008-01-30 05:30:36 -07:00
|
|
|
ti->cpu; \
|
|
|
|
})
|
2007-05-09 02:33:28 -07:00
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
/*
|
2008-01-30 05:30:36 -07: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 05:30:36 -07:00
|
|
|
static inline int num_booting_cpus(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-01-30 05:30:36 -07:00
|
|
|
return cpus_weight(cpu_callout_map);
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
2008-01-30 05:30:36 -07:00
|
|
|
#else /* CONFIG_SMP */
|
2005-04-16 15:20:36 -07:00
|
|
|
#define stack_smp_processor_id() 0
|
2008-01-30 05:30:36 -07:00
|
|
|
|
|
|
|
#endif /* !CONFIG_SMP */
|
|
|
|
|
|
|
|
#define safe_smp_processor_id() smp_processor_id()
|
2005-04-16 15:20:36 -07:00
|
|
|
|
2008-03-23 01:03:30 -07:00
|
|
|
static inline int logical_smp_processor_id(void)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
|
|
|
/* we don't want to mark this access volatile - bad code generation */
|
2008-01-30 05:30:36 -07:00
|
|
|
return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
|
|
|
|
}
|
|
|
|
|
2008-03-19 10:25:53 -07:00
|
|
|
#include <mach_apicdef.h>
|
2008-01-30 05:30:36 -07: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
|
|
|
|
|