blob: 0b2513468870e9461ef4a853887aa1773018b493 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef __ASM_SMP_H
2#define __ASM_SMP_H
3
Thomas Gleixnerae9d9832008-01-30 13:30:36 +01004#ifndef __ASSEMBLY__
5#include <linux/cpumask.h>
6#include <linux/init.h>
7
Linus Torvalds1da177e2005-04-16 15:20:36 -07008/*
9 * We need the APIC definitions automatically as part of 'smp.h'
10 */
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010011#ifdef CONFIG_X86_LOCAL_APIC
12# include <asm/mpspec.h>
13# include <asm/apic.h>
14# ifdef CONFIG_X86_IO_APIC
15# include <asm/io_apic.h>
16# endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070017#endif
18
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010019extern cpumask_t cpu_callin_map;
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010021extern void (*mtrr_hook) (void);
22extern void zap_low_mappings (void);
23
Glauber Costa5382e892008-03-03 14:12:57 -030024extern u16 __initdata x86_cpu_to_apicid_init[];
travis@sgi.com3b419082008-01-30 13:33:11 +010025extern void *x86_cpu_to_apicid_early_ptr;
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010026
27DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
28DECLARE_PER_CPU(cpumask_t, cpu_core_map);
Glauber Costa5382e892008-03-03 14:12:57 -030029DECLARE_PER_CPU(u16, cpu_llc_id);
30DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
Linus Torvalds1da177e2005-04-16 15:20:36 -070031
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010032#ifdef CONFIG_SMP
Zachary Amsdenae5da272007-02-13 13:26:21 +010033#ifndef CONFIG_PARAVIRT
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010034#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
Zachary Amsdenae5da272007-02-13 13:26:21 +010035#endif
36
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010037extern int __cpu_disable(void);
38extern void __cpu_die(unsigned int cpu);
39
Linus Torvalds1da177e2005-04-16 15:20:36 -070040/*
41 * This function is needed by all SMP systems. It must _always_ be valid
42 * from the initial startup. We map APIC_BASE very early in page_setup(),
43 * so this is correct in the x86 case.
44 */
Jeremy Fitzhardinge7c3576d2007-05-02 19:27:16 +020045DECLARE_PER_CPU(int, cpu_number);
46#define raw_smp_processor_id() (x86_read_percpu(cpu_number))
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010048#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
49
50extern int safe_smp_processor_id(void);
51
52void __cpuinit smp_store_cpu_info(int id);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54/* We don't mark CPUs online until __cpu_up(), so we need another measure */
55static inline int num_booting_cpus(void)
56{
57 return cpus_weight(cpu_callout_map);
58}
59
Fernando Luis Vazquez Caoa36166c2007-05-09 02:33:27 -070060#else /* CONFIG_SMP */
61
62#define safe_smp_processor_id() 0
63#define cpu_physical_id(cpu) boot_cpu_physical_apicid
64
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010065#endif /* !CONFIG_SMP */
Fernando Luis Vazquez Caoa36166c2007-05-09 02:33:27 -070066
Linus Torvalds1da177e2005-04-16 15:20:36 -070067#ifdef CONFIG_X86_LOCAL_APIC
68
Andi Kleen874c4fe2006-09-26 10:52:26 +020069static __inline int logical_smp_processor_id(void)
70{
71 /* we don't want to mark this access volatile - bad code generation */
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010072 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
Andi Kleen874c4fe2006-09-26 10:52:26 +020073}
Andi Kleen874c4fe2006-09-26 10:52:26 +020074
Thomas Gleixnerae9d9832008-01-30 13:30:36 +010075# ifdef APIC_DEFINITION
76extern int hard_smp_processor_id(void);
77# else
78# include <mach_apicdef.h>
79static inline int hard_smp_processor_id(void)
80{
81 /* we don't want to mark this access volatile - bad code generation */
82 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
83}
84# endif /* APIC_DEFINITION */
85
86#else /* CONFIG_X86_LOCAL_APIC */
87
88# ifndef CONFIG_SMP
89# define hard_smp_processor_id() 0
90# endif
91
92#endif /* CONFIG_X86_LOCAL_APIC */
93
94#endif /* !ASSEMBLY */
Linus Torvalds1da177e2005-04-16 15:20:36 -070095#endif