1#ifndef __LINUX_SMP_H
2#define __LINUX_SMP_H
3
4
5
6
7
8
9#include <linux/config.h>
10
11extern void cpu_idle(void);
12
13#ifdef CONFIG_SMP
14
15#include <linux/preempt.h>
16#include <linux/kernel.h>
17#include <linux/compiler.h>
18#include <linux/thread_info.h>
19#include <asm/smp.h>
20#include <asm/bug.h>
21
22
23
24
25
26
27
28
29
30extern void smp_send_stop(void);
31
32
33
34
35extern void smp_send_reschedule(int cpu);
36
37
38
39
40
41extern void smp_prepare_cpus(unsigned int max_cpus);
42
43
44
45
46extern int __cpu_up(unsigned int cpunum);
47
48
49
50
51extern void smp_cpus_done(unsigned int max_cpus);
52
53
54
55
56extern int smp_call_function (void (*func) (void *info), void *info,
57 int retry, int wait);
58
59
60
61
62static inline int on_each_cpu(void (*func) (void *info), void *info,
63 int retry, int wait)
64{
65 int ret = 0;
66
67 preempt_disable();
68 ret = smp_call_function(func, info, retry, wait);
69 func(info);
70 preempt_enable();
71 return ret;
72}
73
74
75
76
77extern int smp_threads_ready;
78
79#define MSG_ALL_BUT_SELF 0x8000
80#define MSG_ALL 0x8001
81
82#define MSG_INVALIDATE_TLB 0x0001
83#define MSG_STOP_CPU 0x0002
84
85
86#define MSG_RESCHEDULE 0x0003
87#define MSG_CALL_FUNCTION 0x0004
88
89
90
91
92
93void smp_prepare_boot_cpu(void);
94
95#else
96
97
98
99
100
101#if !defined(__smp_processor_id) || !defined(CONFIG_PREEMPT)
102# define smp_processor_id() 0
103#endif
104#define hard_smp_processor_id() 0
105#define smp_threads_ready 1
106#define smp_call_function(func,info,retry,wait) ({ 0; })
107#define on_each_cpu(func,info,retry,wait) ({ func(info); 0; })
108static inline void smp_send_reschedule(int cpu) { }
109#define num_booting_cpus() 1
110#define smp_prepare_boot_cpu() do {} while (0)
111
112#endif
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130#ifdef __smp_processor_id
131# if defined(CONFIG_PREEMPT) && defined(CONFIG_DEBUG_PREEMPT)
132 extern unsigned int smp_processor_id(void);
133# else
134# define smp_processor_id() __smp_processor_id()
135# endif
136# define _smp_processor_id() __smp_processor_id()
137#else
138# define _smp_processor_id() smp_processor_id()
139#endif
140
141#define get_cpu() ({ preempt_disable(); smp_processor_id(); })
142#define put_cpu() preempt_enable()
143#define put_cpu_no_resched() preempt_enable_no_resched()
144
145#endif
146