Glauber Costa | c27cfef | 2008-03-03 14:12:29 -0300 | [diff] [blame] | 1 | #ifndef _ASM_X86_SMP_H_ |
| 2 | #define _ASM_X86_SMP_H_ |
| 3 | #ifndef __ASSEMBLY__ |
Glauber Costa | 53ebef4 | 2008-03-03 14:12:31 -0300 | [diff] [blame] | 4 | #include <linux/cpumask.h> |
Glauber Costa | 93b016f | 2008-03-03 14:12:40 -0300 | [diff] [blame] | 5 | #include <linux/init.h> |
Glauber de Oliveira Costa | 7e1efc0 | 2008-03-19 14:25:18 -0300 | [diff] [blame] | 6 | #include <asm/percpu.h> |
Glauber Costa | 53ebef4 | 2008-03-03 14:12:31 -0300 | [diff] [blame] | 7 | |
| 8 | extern cpumask_t cpu_callout_map; |
| 9 | |
| 10 | extern int smp_num_siblings; |
| 11 | extern unsigned int num_processors; |
Glauber de Oliveira Costa | cb3c8b9 | 2008-03-19 14:25:59 -0300 | [diff] [blame] | 12 | extern cpumask_t cpu_initialized; |
Glauber Costa | c27cfef | 2008-03-03 14:12:29 -0300 | [diff] [blame] | 13 | |
Glauber de Oliveira Costa | 7e1efc0 | 2008-03-19 14:25:18 -0300 | [diff] [blame] | 14 | extern u16 x86_cpu_to_apicid_init[]; |
| 15 | extern u16 x86_bios_cpu_apicid_init[]; |
| 16 | extern void *x86_cpu_to_apicid_early_ptr; |
| 17 | extern void *x86_bios_cpu_apicid_early_ptr; |
| 18 | |
| 19 | DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); |
| 20 | DECLARE_PER_CPU(cpumask_t, cpu_core_map); |
| 21 | DECLARE_PER_CPU(u16, cpu_llc_id); |
| 22 | DECLARE_PER_CPU(u16, x86_cpu_to_apicid); |
| 23 | DECLARE_PER_CPU(u16, x86_bios_cpu_apicid); |
| 24 | |
Glauber Costa | 4206882 | 2008-03-03 14:13:09 -0300 | [diff] [blame] | 25 | /* |
| 26 | * Trampoline 80x86 program as an array. |
| 27 | */ |
| 28 | extern const unsigned char trampoline_data []; |
| 29 | extern const unsigned char trampoline_end []; |
Glauber Costa | 91718e8 | 2008-03-03 14:13:12 -0300 | [diff] [blame] | 30 | extern unsigned char *trampoline_base; |
Glauber Costa | 4206882 | 2008-03-03 14:13:09 -0300 | [diff] [blame] | 31 | |
Glauber de Oliveira Costa | 9d97d0d | 2008-03-19 14:25:57 -0300 | [diff] [blame] | 32 | /* Static state in head.S used to set up a CPU */ |
| 33 | extern struct { |
| 34 | void *sp; |
| 35 | unsigned short ss; |
| 36 | } stack_start; |
| 37 | |
Glauber de Oliveira Costa | cb3c8b9 | 2008-03-19 14:25:59 -0300 | [diff] [blame] | 38 | extern unsigned long init_rsp; |
| 39 | extern unsigned long initial_code; |
Glauber de Oliveira Costa | 9d97d0d | 2008-03-19 14:25:57 -0300 | [diff] [blame] | 40 | |
Glauber Costa | 1669402 | 2008-03-03 14:12:32 -0300 | [diff] [blame] | 41 | struct smp_ops { |
| 42 | void (*smp_prepare_boot_cpu)(void); |
| 43 | void (*smp_prepare_cpus)(unsigned max_cpus); |
| 44 | int (*cpu_up)(unsigned cpu); |
| 45 | void (*smp_cpus_done)(unsigned max_cpus); |
| 46 | |
| 47 | void (*smp_send_stop)(void); |
| 48 | void (*smp_send_reschedule)(int cpu); |
| 49 | int (*smp_call_function_mask)(cpumask_t mask, |
| 50 | void (*func)(void *info), void *info, |
| 51 | int wait); |
| 52 | }; |
| 53 | |
Glauber Costa | 1452207 | 2008-03-03 14:12:59 -0300 | [diff] [blame] | 54 | /* Globals due to paravirt */ |
| 55 | extern void set_cpu_sibling_map(int cpu); |
| 56 | |
Glauber Costa | c76cb36 | 2008-03-03 14:12:33 -0300 | [diff] [blame] | 57 | #ifdef CONFIG_SMP |
Glauber de Oliveira Costa | d0173ae | 2008-03-19 14:24:59 -0300 | [diff] [blame] | 58 | #ifndef CONFIG_PARAVIRT |
| 59 | #define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0) |
| 60 | #endif |
Glauber Costa | c76cb36 | 2008-03-03 14:12:33 -0300 | [diff] [blame] | 61 | extern struct smp_ops smp_ops; |
Glauber Costa | 8678969 | 2008-03-03 14:12:34 -0300 | [diff] [blame] | 62 | |
Glauber Costa | 377d698 | 2008-03-03 14:12:51 -0300 | [diff] [blame] | 63 | static inline void smp_send_stop(void) |
| 64 | { |
| 65 | smp_ops.smp_send_stop(); |
| 66 | } |
| 67 | |
Glauber Costa | 1e3fac8 | 2008-03-03 14:12:37 -0300 | [diff] [blame] | 68 | static inline void smp_prepare_boot_cpu(void) |
| 69 | { |
| 70 | smp_ops.smp_prepare_boot_cpu(); |
| 71 | } |
| 72 | |
Glauber Costa | 7557da6 | 2008-03-03 14:12:38 -0300 | [diff] [blame] | 73 | static inline void smp_prepare_cpus(unsigned int max_cpus) |
| 74 | { |
| 75 | smp_ops.smp_prepare_cpus(max_cpus); |
| 76 | } |
| 77 | |
Glauber Costa | c559764 | 2008-03-03 14:12:39 -0300 | [diff] [blame] | 78 | static inline void smp_cpus_done(unsigned int max_cpus) |
| 79 | { |
| 80 | smp_ops.smp_cpus_done(max_cpus); |
| 81 | } |
| 82 | |
Glauber Costa | 71d1954 | 2008-03-03 14:12:36 -0300 | [diff] [blame] | 83 | static inline int __cpu_up(unsigned int cpu) |
| 84 | { |
| 85 | return smp_ops.cpu_up(cpu); |
| 86 | } |
| 87 | |
Glauber Costa | 8678969 | 2008-03-03 14:12:34 -0300 | [diff] [blame] | 88 | static inline void smp_send_reschedule(int cpu) |
| 89 | { |
| 90 | smp_ops.smp_send_reschedule(cpu); |
| 91 | } |
Glauber Costa | 64b1a21e0 | 2008-03-03 14:12:35 -0300 | [diff] [blame] | 92 | |
| 93 | static inline int smp_call_function_mask(cpumask_t mask, |
| 94 | void (*func) (void *info), void *info, |
| 95 | int wait) |
| 96 | { |
| 97 | return smp_ops.smp_call_function_mask(mask, func, info, wait); |
| 98 | } |
Glauber Costa | 71d1954 | 2008-03-03 14:12:36 -0300 | [diff] [blame] | 99 | |
Glauber Costa | 1e3fac8 | 2008-03-03 14:12:37 -0300 | [diff] [blame] | 100 | void native_smp_prepare_boot_cpu(void); |
Glauber Costa | 7557da6 | 2008-03-03 14:12:38 -0300 | [diff] [blame] | 101 | void native_smp_prepare_cpus(unsigned int max_cpus); |
Glauber Costa | c559764 | 2008-03-03 14:12:39 -0300 | [diff] [blame] | 102 | void native_smp_cpus_done(unsigned int max_cpus); |
Glauber Costa | 71d1954 | 2008-03-03 14:12:36 -0300 | [diff] [blame] | 103 | int native_cpu_up(unsigned int cpunum); |
Glauber Costa | 93b016f | 2008-03-03 14:12:40 -0300 | [diff] [blame] | 104 | |
Glauber Costa | 69c18c1 | 2008-03-03 14:13:07 -0300 | [diff] [blame] | 105 | extern int __cpu_disable(void); |
| 106 | extern void __cpu_die(unsigned int cpu); |
| 107 | |
Glauber Costa | 93b016f | 2008-03-03 14:12:40 -0300 | [diff] [blame] | 108 | extern unsigned disabled_cpus; |
Glauber Costa | 68a1c3f | 2008-03-03 14:12:42 -0300 | [diff] [blame] | 109 | extern void prefill_possible_map(void); |
Glauber Costa | 91718e8 | 2008-03-03 14:13:12 -0300 | [diff] [blame] | 110 | |
| 111 | #define SMP_TRAMPOLINE_BASE 0x6000 |
| 112 | extern unsigned long setup_trampoline(void); |
Glauber de Oliveira Costa | 1d89a7f | 2008-03-19 14:25:05 -0300 | [diff] [blame] | 113 | |
| 114 | void smp_store_cpu_info(int id); |
Glauber de Oliveira Costa | c70dcb7 | 2008-03-19 14:25:58 -0300 | [diff] [blame] | 115 | #define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu) |
| 116 | #else |
| 117 | #define cpu_physical_id(cpu) boot_cpu_physical_apicid |
Glauber Costa | c76cb36 | 2008-03-03 14:12:33 -0300 | [diff] [blame] | 118 | #endif |
Glauber Costa | 1669402 | 2008-03-03 14:12:32 -0300 | [diff] [blame] | 119 | |
Thomas Gleixner | 96a388d | 2007-10-11 11:20:03 +0200 | [diff] [blame] | 120 | #ifdef CONFIG_X86_32 |
| 121 | # include "smp_32.h" |
| 122 | #else |
| 123 | # include "smp_64.h" |
| 124 | #endif |
Glauber Costa | c27cfef | 2008-03-03 14:12:29 -0300 | [diff] [blame] | 125 | |
Glauber Costa | 1b00084 | 2008-03-27 14:05:58 -0300 | [diff] [blame] | 126 | #ifdef CONFIG_X86_LOCAL_APIC |
| 127 | |
| 128 | static inline int logical_smp_processor_id(void) |
| 129 | { |
| 130 | /* we don't want to mark this access volatile - bad code generation */ |
| 131 | return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR)); |
| 132 | } |
| 133 | |
| 134 | # ifdef APIC_DEFINITION |
| 135 | extern int hard_smp_processor_id(void); |
| 136 | # else |
| 137 | # include <mach_apicdef.h> |
| 138 | static inline int hard_smp_processor_id(void) |
| 139 | { |
| 140 | /* we don't want to mark this access volatile - bad code generation */ |
| 141 | return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID)); |
| 142 | } |
| 143 | # endif /* APIC_DEFINITION */ |
| 144 | |
| 145 | #else /* CONFIG_X86_LOCAL_APIC */ |
| 146 | |
| 147 | # ifndef CONFIG_SMP |
| 148 | # define hard_smp_processor_id() 0 |
| 149 | # endif |
| 150 | |
| 151 | #endif /* CONFIG_X86_LOCAL_APIC */ |
| 152 | |
Glauber Costa | 1dbb472 | 2008-03-03 14:13:01 -0300 | [diff] [blame] | 153 | #ifdef CONFIG_HOTPLUG_CPU |
| 154 | extern void cpu_exit_clear(void); |
| 155 | extern void cpu_uninit(void); |
| 156 | extern void remove_siblinginfo(int cpu); |
| 157 | #endif |
| 158 | |
Glauber Costa | 639acb1 | 2008-03-03 14:12:30 -0300 | [diff] [blame] | 159 | extern void smp_alloc_memory(void); |
| 160 | extern void lock_ipi_call_lock(void); |
| 161 | extern void unlock_ipi_call_lock(void); |
Glauber Costa | c27cfef | 2008-03-03 14:12:29 -0300 | [diff] [blame] | 162 | #endif /* __ASSEMBLY__ */ |
| 163 | #endif |