blob: 2ad2f4ffe498e377a30452f89219fc7a05dcf12b [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 Costac27cfef2008-03-03 14:12:29 -030012
Glauber de Oliveira Costa7e1efc02008-03-19 14:25:18 -030013extern u16 x86_cpu_to_apicid_init[];
14extern u16 x86_bios_cpu_apicid_init[];
15extern void *x86_cpu_to_apicid_early_ptr;
16extern void *x86_bios_cpu_apicid_early_ptr;
17
18DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
19DECLARE_PER_CPU(cpumask_t, cpu_core_map);
20DECLARE_PER_CPU(u16, cpu_llc_id);
21DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
22DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
23
Glauber Costa42068822008-03-03 14:13:09 -030024/*
25 * Trampoline 80x86 program as an array.
26 */
27extern const unsigned char trampoline_data [];
28extern const unsigned char trampoline_end [];
Glauber Costa91718e82008-03-03 14:13:12 -030029extern unsigned char *trampoline_base;
Glauber Costa42068822008-03-03 14:13:09 -030030
Glauber de Oliveira Costa9d97d0d2008-03-19 14:25:57 -030031/* Static state in head.S used to set up a CPU */
32extern struct {
33 void *sp;
34 unsigned short ss;
35} stack_start;
36
37
Glauber Costa16694022008-03-03 14:12:32 -030038struct smp_ops {
39 void (*smp_prepare_boot_cpu)(void);
40 void (*smp_prepare_cpus)(unsigned max_cpus);
41 int (*cpu_up)(unsigned cpu);
42 void (*smp_cpus_done)(unsigned max_cpus);
43
44 void (*smp_send_stop)(void);
45 void (*smp_send_reschedule)(int cpu);
46 int (*smp_call_function_mask)(cpumask_t mask,
47 void (*func)(void *info), void *info,
48 int wait);
49};
50
Glauber Costa14522072008-03-03 14:12:59 -030051/* Globals due to paravirt */
52extern void set_cpu_sibling_map(int cpu);
53
Glauber Costac76cb362008-03-03 14:12:33 -030054#ifdef CONFIG_SMP
Glauber de Oliveira Costad0173ae2008-03-19 14:24:59 -030055#ifndef CONFIG_PARAVIRT
56#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
57#endif
Glauber Costac76cb362008-03-03 14:12:33 -030058extern struct smp_ops smp_ops;
Glauber Costa86789692008-03-03 14:12:34 -030059
Glauber Costa377d6982008-03-03 14:12:51 -030060static inline void smp_send_stop(void)
61{
62 smp_ops.smp_send_stop();
63}
64
Glauber Costa1e3fac82008-03-03 14:12:37 -030065static inline void smp_prepare_boot_cpu(void)
66{
67 smp_ops.smp_prepare_boot_cpu();
68}
69
Glauber Costa7557da62008-03-03 14:12:38 -030070static inline void smp_prepare_cpus(unsigned int max_cpus)
71{
72 smp_ops.smp_prepare_cpus(max_cpus);
73}
74
Glauber Costac5597642008-03-03 14:12:39 -030075static inline void smp_cpus_done(unsigned int max_cpus)
76{
77 smp_ops.smp_cpus_done(max_cpus);
78}
79
Glauber Costa71d19542008-03-03 14:12:36 -030080static inline int __cpu_up(unsigned int cpu)
81{
82 return smp_ops.cpu_up(cpu);
83}
84
Glauber Costa86789692008-03-03 14:12:34 -030085static inline void smp_send_reschedule(int cpu)
86{
87 smp_ops.smp_send_reschedule(cpu);
88}
Glauber Costa64b1a21e02008-03-03 14:12:35 -030089
90static inline int smp_call_function_mask(cpumask_t mask,
91 void (*func) (void *info), void *info,
92 int wait)
93{
94 return smp_ops.smp_call_function_mask(mask, func, info, wait);
95}
Glauber Costa71d19542008-03-03 14:12:36 -030096
Glauber Costa1e3fac82008-03-03 14:12:37 -030097void native_smp_prepare_boot_cpu(void);
Glauber Costa7557da62008-03-03 14:12:38 -030098void native_smp_prepare_cpus(unsigned int max_cpus);
Glauber Costac5597642008-03-03 14:12:39 -030099void native_smp_cpus_done(unsigned int max_cpus);
Glauber Costa71d19542008-03-03 14:12:36 -0300100int native_cpu_up(unsigned int cpunum);
Glauber Costa93b016f2008-03-03 14:12:40 -0300101
Glauber Costa69c18c12008-03-03 14:13:07 -0300102extern int __cpu_disable(void);
103extern void __cpu_die(unsigned int cpu);
104
Glauber Costa93b016f2008-03-03 14:12:40 -0300105extern unsigned disabled_cpus;
Glauber Costa68a1c3f2008-03-03 14:12:42 -0300106extern void prefill_possible_map(void);
Glauber Costa91718e82008-03-03 14:13:12 -0300107
108#define SMP_TRAMPOLINE_BASE 0x6000
109extern unsigned long setup_trampoline(void);
Glauber de Oliveira Costa1d89a7f2008-03-19 14:25:05 -0300110
111void smp_store_cpu_info(int id);
Glauber de Oliveira Costac70dcb72008-03-19 14:25:58 -0300112#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
113#else
114#define cpu_physical_id(cpu) boot_cpu_physical_apicid
Glauber Costac76cb362008-03-03 14:12:33 -0300115#endif
Glauber Costa16694022008-03-03 14:12:32 -0300116
Thomas Gleixner96a388d2007-10-11 11:20:03 +0200117#ifdef CONFIG_X86_32
118# include "smp_32.h"
119#else
120# include "smp_64.h"
121#endif
Glauber Costac27cfef2008-03-03 14:12:29 -0300122
Glauber Costa1dbb4722008-03-03 14:13:01 -0300123#ifdef CONFIG_HOTPLUG_CPU
124extern void cpu_exit_clear(void);
125extern void cpu_uninit(void);
126extern void remove_siblinginfo(int cpu);
127#endif
128
Glauber Costa639acb12008-03-03 14:12:30 -0300129extern void smp_alloc_memory(void);
130extern void lock_ipi_call_lock(void);
131extern void unlock_ipi_call_lock(void);
Glauber Costac27cfef2008-03-03 14:12:29 -0300132#endif /* __ASSEMBLY__ */
133#endif