1#ifndef _LINUX_INIT_H
2#define _LINUX_INIT_H
3
4#include <linux/config.h>
5
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#ifndef MODULE
42
43#ifndef __ASSEMBLY__
44
45
46
47
48typedef int (*initcall_t)(void);
49typedef void (*exitcall_t)(void);
50
51extern initcall_t __initcall_start, __initcall_end;
52
53
54
55
56
57
58
59
60#define __define_initcall(level,fn) \
61 static initcall_t __initcall_##fn __attribute__ ((unused,__section__ (".initcall" level ".init"))) = fn
62
63#define core_initcall(fn) __define_initcall("1",fn)
64#define postcore_initcall(fn) __define_initcall("2",fn)
65#define arch_initcall(fn) __define_initcall("3",fn)
66#define subsys_initcall(fn) __define_initcall("4",fn)
67#define fs_initcall(fn) __define_initcall("5",fn)
68#define device_initcall(fn) __define_initcall("6",fn)
69#define late_initcall(fn) __define_initcall("7",fn)
70
71#define __initcall(fn) device_initcall(fn)
72
73#define __exitcall(fn) \
74 static exitcall_t __exitcall_##fn __exit_call = fn
75
76
77
78
79struct kernel_param {
80 const char *str;
81 int (*setup_func)(char *);
82};
83
84extern struct kernel_param __setup_start, __setup_end;
85
86#define __setup(str, fn) \
87 static char __setup_str_##fn[] __initdata = str; \
88 static struct kernel_param __setup_##fn __attribute__((unused)) __initsetup = { __setup_str_##fn, fn }
89
90#endif
91
92
93
94
95
96#define __init __attribute__ ((__section__ (".text.init")))
97#define __exit __attribute__ ((unused, __section__(".text.exit")))
98#define __initdata __attribute__ ((__section__ (".data.init")))
99#define __exitdata __attribute__ ((unused, __section__ (".data.exit")))
100#define __initsetup __attribute__ ((unused,__section__ (".setup.init")))
101#define __init_call(level) __attribute__ ((unused,__section__ (".initcall" level ".init")))
102#define __exit_call __attribute__ ((unused,__section__ (".exitcall.exit")))
103
104
105#define __INIT .section ".text.init","ax"
106#define __FINIT .previous
107#define __INITDATA .section ".data.init","aw"
108
109
110
111
112
113
114
115
116
117
118
119#define module_init(x) __initcall(x);
120
121
122
123
124
125
126
127
128
129
130#define module_exit(x) __exitcall(x);
131
132#else
133
134#define __init
135#define __exit
136#define __initdata
137#define __exitdata
138#define __initcall(fn)
139
140#define __INIT
141#define __FINIT
142#define __INITDATA
143
144
145
146
147
148
149typedef int (*__init_module_func_t)(void);
150typedef void (*__cleanup_module_func_t)(void);
151#define module_init(x) \
152 int init_module(void) __attribute__((alias(#x))); \
153 static inline __init_module_func_t __init_module_inline(void) \
154 { return x; }
155#define module_exit(x) \
156 void cleanup_module(void) __attribute__((alias(#x))); \
157 static inline __cleanup_module_func_t __cleanup_module_inline(void) \
158 { return x; }
159
160#define __setup(str,func)
161
162#define core_initcall(fn) module_init(fn)
163#define postcore_initcall(fn) module_init(fn)
164#define arch_initcall(fn) module_init(fn)
165#define subsys_initcall(fn) module_init(fn)
166#define fs_initcall(fn) module_init(fn)
167#define device_initcall(fn) module_init(fn)
168#define late_initcall(fn) module_init(fn)
169
170#endif
171
172
173#define __nosavedata __attribute__ ((__section__ (".data.nosave")))
174
175#ifdef CONFIG_HOTPLUG
176#define __devinit
177#define __devinitdata
178#define __devexit
179#define __devexitdata
180#define __devexit_p(x) &(x)
181#else
182#define __devinit __init
183#define __devinitdata __initdata
184#define __devexit __exit
185#define __devexitdata __exitdata
186#define __devexit_p(x) 0
187#endif
188
189#endif
190