x86: split safe_smp_processor_id
[deliverable/linux.git] / include / asm-x86 / smp.h
CommitLineData
c27cfeff
GC
1#ifndef _ASM_X86_SMP_H_
2#define _ASM_X86_SMP_H_
3#ifndef __ASSEMBLY__
53ebef49 4#include <linux/cpumask.h>
93b016f8 5#include <linux/init.h>
7e1efc0c 6#include <asm/percpu.h>
53ebef49 7
b23dab08
GC
8/*
9 * We need the APIC definitions automatically as part of 'smp.h'
10 */
11#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
17#endif
18#include <asm/pda.h>
19#include <asm/thread_info.h>
20
53ebef49
GC
21extern cpumask_t cpu_callout_map;
22
23extern int smp_num_siblings;
24extern unsigned int num_processors;
cb3c8b90 25extern cpumask_t cpu_initialized;
c27cfeff 26
7e1efc0c
GOC
27extern u16 x86_cpu_to_apicid_init[];
28extern u16 x86_bios_cpu_apicid_init[];
29extern void *x86_cpu_to_apicid_early_ptr;
30extern void *x86_bios_cpu_apicid_early_ptr;
31
32DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
33DECLARE_PER_CPU(cpumask_t, cpu_core_map);
34DECLARE_PER_CPU(u16, cpu_llc_id);
35DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
36DECLARE_PER_CPU(u16, x86_bios_cpu_apicid);
37
42068829
GC
38/*
39 * Trampoline 80x86 program as an array.
40 */
41extern const unsigned char trampoline_data [];
42extern const unsigned char trampoline_end [];
91718e8d 43extern unsigned char *trampoline_base;
42068829 44
9d97d0da
GOC
45/* Static state in head.S used to set up a CPU */
46extern struct {
47 void *sp;
48 unsigned short ss;
49} stack_start;
50
cb3c8b90
GOC
51extern unsigned long init_rsp;
52extern unsigned long initial_code;
9d97d0da 53
16694024
GC
54struct smp_ops {
55 void (*smp_prepare_boot_cpu)(void);
56 void (*smp_prepare_cpus)(unsigned max_cpus);
57 int (*cpu_up)(unsigned cpu);
58 void (*smp_cpus_done)(unsigned max_cpus);
59
60 void (*smp_send_stop)(void);
61 void (*smp_send_reschedule)(int cpu);
62 int (*smp_call_function_mask)(cpumask_t mask,
63 void (*func)(void *info), void *info,
64 int wait);
65};
66
14522076
GC
67/* Globals due to paravirt */
68extern void set_cpu_sibling_map(int cpu);
69
c76cb368 70#ifdef CONFIG_SMP
d0173aea
GOC
71#ifndef CONFIG_PARAVIRT
72#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
73#endif
c76cb368 74extern struct smp_ops smp_ops;
8678969e 75
377d6984
GC
76static inline void smp_send_stop(void)
77{
78 smp_ops.smp_send_stop();
79}
80
1e3fac83
GC
81static inline void smp_prepare_boot_cpu(void)
82{
83 smp_ops.smp_prepare_boot_cpu();
84}
85
7557da67
GC
86static inline void smp_prepare_cpus(unsigned int max_cpus)
87{
88 smp_ops.smp_prepare_cpus(max_cpus);
89}
90
c5597649
GC
91static inline void smp_cpus_done(unsigned int max_cpus)
92{
93 smp_ops.smp_cpus_done(max_cpus);
94}
95
71d19549
GC
96static inline int __cpu_up(unsigned int cpu)
97{
98 return smp_ops.cpu_up(cpu);
99}
100
8678969e
GC
101static inline void smp_send_reschedule(int cpu)
102{
103 smp_ops.smp_send_reschedule(cpu);
104}
64b1a21e
GC
105
106static inline int smp_call_function_mask(cpumask_t mask,
107 void (*func) (void *info), void *info,
108 int wait)
109{
110 return smp_ops.smp_call_function_mask(mask, func, info, wait);
111}
71d19549 112
1e3fac83 113void native_smp_prepare_boot_cpu(void);
7557da67 114void native_smp_prepare_cpus(unsigned int max_cpus);
c5597649 115void native_smp_cpus_done(unsigned int max_cpus);
71d19549 116int native_cpu_up(unsigned int cpunum);
93b016f8 117
69c18c15
GC
118extern int __cpu_disable(void);
119extern void __cpu_die(unsigned int cpu);
120
93b016f8 121extern unsigned disabled_cpus;
68a1c3f8 122extern void prefill_possible_map(void);
91718e8d
GC
123
124#define SMP_TRAMPOLINE_BASE 0x6000
125extern unsigned long setup_trampoline(void);
1d89a7f0
GOC
126
127void smp_store_cpu_info(int id);
c70dcb74
GOC
128#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)
129#else
130#define cpu_physical_id(cpu) boot_cpu_physical_apicid
c76cb368 131#endif
16694024 132
96a388de
TG
133#ifdef CONFIG_X86_32
134# include "smp_32.h"
135#else
136# include "smp_64.h"
137#endif
c27cfeff 138
1b000843
GC
139#ifdef CONFIG_X86_LOCAL_APIC
140
141static inline int logical_smp_processor_id(void)
142{
143 /* we don't want to mark this access volatile - bad code generation */
144 return GET_APIC_LOGICAL_ID(*(u32 *)(APIC_BASE + APIC_LDR));
145}
146
147# ifdef APIC_DEFINITION
148extern int hard_smp_processor_id(void);
149# else
150# include <mach_apicdef.h>
151static inline int hard_smp_processor_id(void)
152{
153 /* we don't want to mark this access volatile - bad code generation */
154 return GET_APIC_ID(*(u32 *)(APIC_BASE + APIC_ID));
155}
156# endif /* APIC_DEFINITION */
157
158#else /* CONFIG_X86_LOCAL_APIC */
159
160# ifndef CONFIG_SMP
161# define hard_smp_processor_id() 0
162# endif
163
164#endif /* CONFIG_X86_LOCAL_APIC */
165
1dbb4726
GC
166#ifdef CONFIG_HOTPLUG_CPU
167extern void cpu_exit_clear(void);
168extern void cpu_uninit(void);
169extern void remove_siblinginfo(int cpu);
170#endif
171
639acb16
GC
172extern void smp_alloc_memory(void);
173extern void lock_ipi_call_lock(void);
174extern void unlock_ipi_call_lock(void);
c27cfeff
GC
175#endif /* __ASSEMBLY__ */
176#endif
This page took 0.104012 seconds and 5 git commands to generate.