777static void (*init_machine)(void) __initdata;
778
779static int __init customize_machine(void)
780{
781 /* customizes platform devices, or adds new ones */
782 if (init_machine)
783 init_machine();
784 return 0;
785}
786arch_initcall(customize_machine);
arch_initcall将customize_machine放在特定的段中,系统将在某个地方运行所有的arch_initcall修饰的函数。
152#ifndef MODULE //非可加载模块,即编译链接进内核的代码
153
154#ifndef __ASSEMBLY__
155
156/* initcalls are now grouped by functionality into separate
157 * subsections. Ordering inside the subsections is determined
158 * by link order.
159 * For backwards compatibility, initcall() puts the call in
160 * the device init subsection.
161 *
162 * The `id\' arg to __define_initcall() is needed so that multiple initcalls
163 * can point at the same handler without causing duplicate-symbol build errors.
164 */
165
166#define __define_initcall(level,fn,id) /
167 static initcall_t __initcall_##fn##id __used /
168 __attribute__((__section__(".initcall" level ".init"))) = fn
169
170/*
171 * A "pure" initcall has no dependencies on anything else, and purely
172 * initializes variables that couldn\'t be statically initialized.
173 *
174 * This only exists for built-in code, not for modules.
175 */
176#define pure_initcall(fn) __define_initcall("0",fn,0)
177
178#define core_initcall(fn) __define_initcall("1",fn,1)
179#define core_initcall_sync(fn) __define_initcall("1s",fn,1s)
180#define postcore_initcall(fn) __define_initcall("2",fn,2)
181#define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s)
182#define arch_initcall(fn) __define_initcall("3",fn,3)
183#define arch_initcall_sync(fn) __define_initcall("3s",fn,3s)
184#define subsys_initcall(fn) __define_initcall("4",fn,4)
185#define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s)
186#define fs_initcall(fn) __define_initcall("5",fn,5)
187#define fs_initcall_sync(fn) __define_initcall("5s",fn,5s)
188#define rootfs_initcall(fn) __define_initcall("rootfs",fn,rootfs)
189#define device_initcall(fn) __define_initcall("6",fn,6)
190#define device_initcall_sync(fn) __define_initcall("6s",fn,6s)
191#define late_initcall(fn) __define_initcall("7",fn,7)
192#define late_initcall_sync(fn) __define_initcall("7s",fn,7s)
193
194#define __initcall(fn) device_initcall(fn)
195
196#define __exitcall(fn) /
197 static exitcall_t __exitcall_##fn __exit_call = fn
198
。。。。。。。。。
239#endif /* __ASSEMBLY__ */
240
241/**
242 * module_init() - driver initialization entry point
243 * @x: function to be run at kernel boot time or module insertion
244 *
245 * module_init() will either be called during do_initcalls() (if
246 * builtin) or at module insertion time (if a module). There can only
247 * be one per module.
248 */
249#define module_init(x) __initcall(x);
250
251/**
252 * module_exit() - driver exit entry point
253 * @x: function to be run when driver is removed
254 *
255 * module_exit() will wrap the driver clean-up code
256 * with cleanup_module() when used with rmmod when
257 * the driver is a module. If the driver is statically
258 * compiled into the kernel, module_exit() has no effect.
259 * There can only be one per module.
260 */
261#define module_exit(x) __exitcall(x);
262
263#else /* MODULE */
各种xx_core_initcall被定义到了不同的分级的段中
所以arch_initcall == __initcall_fn3 它将被链接器放于section .initcall3.init. 中
module_init()==__initcall(fn)==device_initcall(fn)== __initcall_fn6