1#ifndef _LINUX_INIT_H
2#define _LINUX_INIT_H
3
4#include <linux/config.h>
5#include <linux/compiler.h>
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44#define __init __attribute__ ((__section__ (".init.text")))
45#define __initdata __attribute__ ((__section__ (".init.data")))
46#define __exitdata __attribute__ ((__section__(".exit.data")))
47#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit")))
48
49#ifdef MODULE
50#define __exit __attribute__ ((__section__(".exit.text")))
51#else
52#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text")))
53#endif
54
55
56#define __INIT .section ".init.text","ax"
57#define __FINIT .previous
58#define __INITDATA .section ".init.data","aw"
59
60#ifndef __ASSEMBLY__
61
62
63
64typedef int (*initcall_t)(void);
65typedef void (*exitcall_t)(void);
66
67extern initcall_t __con_initcall_start, __con_initcall_end;
68extern initcall_t __security_initcall_start, __security_initcall_end;
69
70
71extern char saved_command_line[];
72#endif
73
74#ifndef MODULE
75
76#ifndef __ASSEMBLY__
77
78
79
80
81
82
83
84
85#define __define_initcall(level,fn) \
86 static initcall_t __initcall_##fn __attribute_used__ \
87 __attribute__((__section__(".initcall" level ".init"))) = fn
88
89#define core_initcall(fn) __define_initcall("1",fn)
90#define postcore_initcall(fn) __define_initcall("2",fn)
91#define arch_initcall(fn) __define_initcall("3",fn)
92#define subsys_initcall(fn) __define_initcall("4",fn)
93#define fs_initcall(fn) __define_initcall("5",fn)
94#define device_initcall(fn) __define_initcall("6",fn)
95#define late_initcall(fn) __define_initcall("7",fn)
96
97#define __initcall(fn) device_initcall(fn)
98
99#define __exitcall(fn) \
100 static exitcall_t __exitcall_##fn __exit_call = fn
101
102#define console_initcall(fn) \
103 static initcall_t __initcall_##fn \
104 __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn
105
106#define security_initcall(fn) \
107 static initcall_t __initcall_##fn \
108 __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn
109
110struct obs_kernel_param {
111 const char *str;
112 int (*setup_func)(char *);
113 int early;
114};
115
116
117
118
119
120
121
122#define __setup_param(str, unique_id, fn, early) \
123 static char __setup_str_##unique_id[] __initdata = str; \
124 static struct obs_kernel_param __setup_##unique_id \
125 __attribute_used__ \
126 __attribute__((__section__(".init.setup"))) \
127 __attribute__((aligned((sizeof(long))))) \
128 = { __setup_str_##unique_id, fn, early }
129
130#define __setup_null_param(str, unique_id) \
131 __setup_param(str, unique_id, NULL, 0)
132
133#define __setup(str, fn) \
134 __setup_param(str, fn, fn, 0)
135
136#define __obsolete_setup(str) \
137 __setup_null_param(str, __LINE__)
138
139
140
141#define early_param(str, fn) \
142 __setup_param(str, fn, fn, 1)
143
144
145void __init parse_early_param(void);
146#endif
147
148
149
150
151
152
153
154
155
156#define module_init(x) __initcall(x);
157
158
159
160
161
162
163
164
165
166
167
168#define module_exit(x) __exitcall(x);
169
170#else
171
172
173#define core_initcall(fn) module_init(fn)
174#define postcore_initcall(fn) module_init(fn)
175#define arch_initcall(fn) module_init(fn)
176#define subsys_initcall(fn) module_init(fn)
177#define fs_initcall(fn) module_init(fn)
178#define device_initcall(fn) module_init(fn)
179#define late_initcall(fn) module_init(fn)
180
181#define security_initcall(fn) module_init(fn)
182
183
184
185
186
187
188
189
190#define module_init(initfn) \
191 static inline initcall_t __inittest(void) \
192 { return initfn; } \
193 int init_module(void) __attribute__((alias(#initfn)));
194
195
196#define module_exit(exitfn) \
197 static inline exitcall_t __exittest(void) \
198 { return exitfn; } \
199 void cleanup_module(void) __attribute__((alias(#exitfn)));
200
201#define __setup_param(str, unique_id, fn)
202#define __setup_null_param(str, unique_id)
203#define __setup(str, func)
204#define __obsolete_setup(str)
205#endif
206
207
208#define __nosavedata __attribute__ ((__section__ (".data.nosave")))
209
210
211
212#ifdef CONFIG_MODULES
213#define __init_or_module
214#define __initdata_or_module
215#else
216#define __init_or_module __init
217#define __initdata_or_module __initdata
218#endif
219
220#ifdef CONFIG_HOTPLUG
221#define __devinit
222#define __devinitdata
223#define __devexit
224#define __devexitdata
225#else
226#define __devinit __init
227#define __devinitdata __initdata
228#define __devexit __exit
229#define __devexitdata __exitdata
230#endif
231
232
233
234
235
236
237
238#if defined(MODULE) || defined(CONFIG_HOTPLUG)
239#define __devexit_p(x) x
240#else
241#define __devexit_p(x) NULL
242#endif
243
244#ifdef MODULE
245#define __exit_p(x) x
246#else
247#define __exit_p(x) NULL
248#endif
249
250#endif
251