blob: ef26911dc22a039513a1fa1664af24f209675d98 [file] [log] [blame]
Glauber Costac27cfef2008-03-03 14:12:29 -03001#ifndef _ASM_X86_SMP_H_
2#define _ASM_X86_SMP_H_
3#ifndef __ASSEMBLY__
Glauber Costa53ebef42008-03-03 14:12:31 -03004#include <linux/cpumask.h>
Glauber Costa93b016f2008-03-03 14:12:40 -03005#include <linux/init.h>
Glauber de Oliveira Costa7e1efc02008-03-19 14:25:18 -03006#include <asm/percpu.h>
Glauber Costa53ebef42008-03-03 14:12:31 -03007
8extern cpumask_t cpu_callout_map;
9
10extern int smp_num_siblings;
11extern unsigned int num_processors;
Glauber de Oliveira Costacb3c8b92008-03-19 14:25:59 -030012extern cpumask_t cpu_initialized;
Glauber Costac27cfef2008-03-03 14:12:29 -030013
Glauber de Oliveira Costa7e1efc02008-03-19 14:25:18 -030014extern u16 x86_cpu_to_apicid_init[];
15extern u16 x86_bios_cpu_apicid_init[];
16extern void *x86_cpu_to_apicid_early_ptr;
17extern void *x86_bios_cpu_apicid_early_ptr;
18
19DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
20DECLARE_PER_CPU(cpumask_t, cpu_core_map);
21DECLARE_PER_CPU(u16, cpu_llc_id);
22DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
23DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
24
Glauber Costa42068822008-03-03 14:13:09 -030025/*
26 * Trampoline 80x86 program as an array.
27 */
28extern const unsigned char trampoline_data [];
29extern const unsigned char trampoline_end [];
Glauber Costa91718e82008-03-03 14:13:12 -030030extern unsigned char *trampoline_base;
Glauber Costa42068822008-03-03 14:13:09 -030031
Glauber de Oliveira Costa9d97d0d2008-03-19 14:25:57 -030032/* Static state in head.S used to set up a CPU */
33extern struct {
34 void *sp;
35 unsigned short ss;
36} stack_start;
37
Glauber de Oliveira Costacb3c8b92008-03-19 14:25:59 -030038extern unsigned long init_rsp;
39extern unsigned long initial_code;
Glauber de Oliveira Costa9d97d0d2008-03-19 14:25:57 -030040
Glauber Costa16694022008-03-03 14:12:32 -030041struct 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 Costa14522072008-03-03 14:12:59 -030054/* Globals due to paravirt */
55extern void set_cpu_sibling_map(int cpu);
56
Glauber Costac76cb362008-03-03 14:12:33 -030057#ifdef CONFIG_SMP
Glauber de Oliveira Costad0173ae2008-03-19 14:24:59 -030058#ifndef CONFIG_PARAVIRT
59#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
60#endif
Glauber Costac76cb362008-03-03 14:12:33 -030061extern struct smp_ops smp_ops;
Glauber Costa86789692008-03-03 14:12:34 -030062
Glauber Costa377d6982008-03-03 14:12:51 -030063static inline void smp_send_stop(void)
64{
65 smp_ops.smp_send_stop();
66}
67
Glauber Costa1e3fac82008-03-03 14:12:37 -030068static inline void smp_prepare_boot_cpu(void)
69{
70 smp_ops.smp_prepare_boot_cpu();
71}
72
Glauber Costa7557da62008-03-03 14:12:38 -030073static inline void smp_prepare_cpus(unsigned int max_cpus)
74{
75 smp_ops.smp_prepare_cpus(max_cpus);
76}
77
Glauber Costac5597642008-03-03 14:12:39 -030078static inline void smp_cpus_done(unsigned int max_cpus)
79{
80 smp_ops.smp_cpus_done(max_cpus);
81}
82
Glauber Costa71d19542008-03-03 14:12:36 -030083static inline int __cpu_up(unsigned int cpu)
84{
85 return smp_ops.cpu_up(cpu);
86}
87
Glauber Costa86789692008-03-03 14:12:34 -030088static inline void smp_send_reschedule(int cpu)
89{
90 smp_ops.smp_send_reschedule(cpu);
91}
Glauber Costa64b1a21e02008-03-03 14:12:35 -030092
93static 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 Costa71d19542008-03-03 14:12:36 -030099
Glauber Costa1e3fac82008-03-03 14:12:37 -0300100void native_smp_prepare_boot_cpu(void);
Glauber Costa7557da62008-03-03 14:12:38 -0300101void native_smp_prepare_cpus(unsigned int max_cpus);
Glauber Costac5597642008-03-03 14:12:39 -0300102void native_smp_cpus_done(unsigned int max_cpus);
Glauber Costa71d19542008-03-03 14:12:36 -0300103int native_cpu_up(unsigned int cpunum);
Glauber Costa93b016f2008-03-03 14:12:40 -0300104
Glauber Costa69c18c12008-03-03 14:13:07 -0300105extern int __cpu_disable(void);
106extern void __cpu_die(unsigned int cpu);
107
Glauber Costa93b016f2008-03-03 14:12:40 -0300108extern unsigned disabled_cpus;
Glauber Costa68a1c3f2008-03-03 14:12:42 -0300109extern void prefill_possible_map(void);
Glauber Costa91718e82008-03-03 14:13:12 -0300110
111#define SMP_TRAMPOLINE_BASE 0x6000
112extern unsigned long setup_trampoline(void);
Glauber de Oliveira Costa1d89a7f2008-03-19 14:25:05 -0300113
114void smp_store_cpu_info(int id);
Glauber de Oliveira Costac70dcb72008-03-19 14:25:58 -0300115#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 Costac76cb362008-03-03 14:12:33 -0300118#endif
Glauber Costa16694022008-03-03 14:12:32 -0300119
Thomas Gleixner96a388d2007-10-11 11:20:03 +0200120#ifdef CONFIG_X86_32
121# include "smp_32.h"
122#else
123# include "smp_64.h"
124#endif
Glauber Costac27cfef2008-03-03 14:12:29 -0300125
Glauber Costa1dbb4722008-03-03 14:13:01 -0300126#ifdef CONFIG_HOTPLUG_CPU
127extern void cpu_exit_clear(void);
128extern void cpu_uninit(void);
129extern void remove_siblinginfo(int cpu);
130#endif
131
Glauber Costa639acb12008-03-03 14:12:30 -0300132extern void smp_alloc_memory(void);
133extern void lock_ipi_call_lock(void);
134extern void unlock_ipi_call_lock(void);
Glauber Costac27cfef2008-03-03 14:12:29 -0300135#endif /* __ASSEMBLY__ */
136#endif