Nicholas Flintham | 1e3d311 | 2013-04-10 10:48:38 +0100 | [diff] [blame^] | 1 | #ifndef _LINUX_INIT_H |
| 2 | #define _LINUX_INIT_H |
| 3 | |
| 4 | #include <linux/compiler.h> |
| 5 | #include <linux/types.h> |
| 6 | |
| 7 | |
| 8 | #define __init __section(.init.text) __cold notrace |
| 9 | #define __initdata __section(.init.data) |
| 10 | #define __initconst __section(.init.rodata) |
| 11 | #define __exitdata __section(.exit.data) |
| 12 | #define __exit_call __used __section(.exitcall.exit) |
| 13 | |
| 14 | #define __ref __section(.ref.text) noinline |
| 15 | #define __refdata __section(.ref.data) |
| 16 | #define __refconst __section(.ref.rodata) |
| 17 | |
| 18 | #define __init_refok __ref |
| 19 | #define __initdata_refok __refdata |
| 20 | #define __exit_refok __ref |
| 21 | |
| 22 | |
| 23 | #ifdef MODULE |
| 24 | #define __exitused |
| 25 | #else |
| 26 | #define __exitused __used |
| 27 | #endif |
| 28 | |
| 29 | #define __exit __section(.exit.text) __exitused __cold notrace |
| 30 | |
| 31 | #define __devinit __section(.devinit.text) __cold notrace |
| 32 | #define __devinitdata __section(.devinit.data) |
| 33 | #define __devinitconst __section(.devinit.rodata) |
| 34 | #define __devexit __section(.devexit.text) __exitused __cold notrace |
| 35 | #define __devexitdata __section(.devexit.data) |
| 36 | #define __devexitconst __section(.devexit.rodata) |
| 37 | |
| 38 | #define __cpuinit __section(.cpuinit.text) __cold notrace |
| 39 | #define __cpuinitdata __section(.cpuinit.data) |
| 40 | #define __cpuinitconst __section(.cpuinit.rodata) |
| 41 | #define __cpuexit __section(.cpuexit.text) __exitused __cold notrace |
| 42 | #define __cpuexitdata __section(.cpuexit.data) |
| 43 | #define __cpuexitconst __section(.cpuexit.rodata) |
| 44 | |
| 45 | #define __meminit __section(.meminit.text) __cold notrace |
| 46 | #define __meminitdata __section(.meminit.data) |
| 47 | #define __meminitconst __section(.meminit.rodata) |
| 48 | #define __memexit __section(.memexit.text) __exitused __cold notrace |
| 49 | #define __memexitdata __section(.memexit.data) |
| 50 | #define __memexitconst __section(.memexit.rodata) |
| 51 | |
| 52 | #define __HEAD .section ".head.text","ax" |
| 53 | #define __INIT .section ".init.text","ax" |
| 54 | #define __FINIT .previous |
| 55 | |
| 56 | #define __INITDATA .section ".init.data","aw",%progbits |
| 57 | #define __INITRODATA .section ".init.rodata","a",%progbits |
| 58 | #define __FINITDATA .previous |
| 59 | |
| 60 | #define __DEVINIT .section ".devinit.text", "ax" |
| 61 | #define __DEVINITDATA .section ".devinit.data", "aw" |
| 62 | #define __DEVINITRODATA .section ".devinit.rodata", "a" |
| 63 | |
| 64 | #define __CPUINIT .section ".cpuinit.text", "ax" |
| 65 | #define __CPUINITDATA .section ".cpuinit.data", "aw" |
| 66 | #define __CPUINITRODATA .section ".cpuinit.rodata", "a" |
| 67 | |
| 68 | #define __MEMINIT .section ".meminit.text", "ax" |
| 69 | #define __MEMINITDATA .section ".meminit.data", "aw" |
| 70 | #define __MEMINITRODATA .section ".meminit.rodata", "a" |
| 71 | |
| 72 | #define __REF .section ".ref.text", "ax" |
| 73 | #define __REFDATA .section ".ref.data", "aw" |
| 74 | #define __REFCONST .section ".ref.rodata", "a" |
| 75 | |
| 76 | #ifndef __ASSEMBLY__ |
| 77 | typedef int (*initcall_t)(void); |
| 78 | typedef void (*exitcall_t)(void); |
| 79 | |
| 80 | extern initcall_t __con_initcall_start[], __con_initcall_end[]; |
| 81 | extern initcall_t __security_initcall_start[], __security_initcall_end[]; |
| 82 | |
| 83 | typedef void (*ctor_fn_t)(void); |
| 84 | |
| 85 | extern int do_one_initcall(initcall_t fn); |
| 86 | extern char __initdata boot_command_line[]; |
| 87 | extern char *saved_command_line; |
| 88 | extern unsigned int reset_devices; |
| 89 | |
| 90 | void setup_arch(char **); |
| 91 | void prepare_namespace(void); |
| 92 | |
| 93 | extern void (*late_time_init)(void); |
| 94 | |
| 95 | extern bool initcall_debug; |
| 96 | |
| 97 | #endif |
| 98 | |
| 99 | #ifndef MODULE |
| 100 | |
| 101 | #ifndef __ASSEMBLY__ |
| 102 | |
| 103 | |
| 104 | #define __define_initcall(level,fn,id) \ |
| 105 | static initcall_t __initcall_##fn##id __used \ |
| 106 | __attribute__((__section__(".initcall" level ".init"))) = fn |
| 107 | |
| 108 | #define early_initcall(fn) __define_initcall("early",fn,early) |
| 109 | |
| 110 | #define pure_initcall(fn) __define_initcall("0",fn,0) |
| 111 | |
| 112 | #define core_initcall(fn) __define_initcall("1",fn,1) |
| 113 | #define core_initcall_sync(fn) __define_initcall("1s",fn,1s) |
| 114 | #define postcore_initcall(fn) __define_initcall("2",fn,2) |
| 115 | #define postcore_initcall_sync(fn) __define_initcall("2s",fn,2s) |
| 116 | #define arch_initcall(fn) __define_initcall("3",fn,3) |
| 117 | #define arch_initcall_sync(fn) __define_initcall("3s",fn,3s) |
| 118 | #define subsys_initcall(fn) __define_initcall("4",fn,4) |
| 119 | #define subsys_initcall_sync(fn) __define_initcall("4s",fn,4s) |
| 120 | #define fs_initcall(fn) __define_initcall("5",fn,5) |
| 121 | #define fs_initcall_sync(fn) __define_initcall("5s",fn,5s) |
| 122 | #define rootfs_initcall(fn) __define_initcall("rootfs",fn,rootfs) |
| 123 | #define device_initcall(fn) __define_initcall("6",fn,6) |
| 124 | #define device_initcall_sync(fn) __define_initcall("6s",fn,6s) |
| 125 | #define late_initcall(fn) __define_initcall("7",fn,7) |
| 126 | #define late_initcall_sync(fn) __define_initcall("7s",fn,7s) |
| 127 | |
| 128 | #define __initcall(fn) device_initcall(fn) |
| 129 | |
| 130 | #define __exitcall(fn) \ |
| 131 | static exitcall_t __exitcall_##fn __exit_call = fn |
| 132 | |
| 133 | #define console_initcall(fn) \ |
| 134 | static initcall_t __initcall_##fn \ |
| 135 | __used __section(.con_initcall.init) = fn |
| 136 | |
| 137 | #define security_initcall(fn) \ |
| 138 | static initcall_t __initcall_##fn \ |
| 139 | __used __section(.security_initcall.init) = fn |
| 140 | |
| 141 | struct obs_kernel_param { |
| 142 | const char *str; |
| 143 | int (*setup_func)(char *); |
| 144 | int early; |
| 145 | }; |
| 146 | |
| 147 | #define __setup_param(str, unique_id, fn, early) \ |
| 148 | static const char __setup_str_##unique_id[] __initconst \ |
| 149 | __aligned(1) = str; \ |
| 150 | static struct obs_kernel_param __setup_##unique_id \ |
| 151 | __used __section(.init.setup) \ |
| 152 | __attribute__((aligned((sizeof(long))))) \ |
| 153 | = { __setup_str_##unique_id, fn, early } |
| 154 | |
| 155 | #define __setup(str, fn) \ |
| 156 | __setup_param(str, fn, fn, 0) |
| 157 | |
| 158 | #define early_param(str, fn) \ |
| 159 | __setup_param(str, fn, fn, 1) |
| 160 | |
| 161 | void __init parse_early_param(void); |
| 162 | void __init parse_early_options(char *cmdline); |
| 163 | #endif |
| 164 | |
| 165 | #define module_init(x) __initcall(x); |
| 166 | |
| 167 | #define module_exit(x) __exitcall(x); |
| 168 | |
| 169 | #else |
| 170 | |
| 171 | #define early_initcall(fn) module_init(fn) |
| 172 | #define core_initcall(fn) module_init(fn) |
| 173 | #define postcore_initcall(fn) module_init(fn) |
| 174 | #define arch_initcall(fn) module_init(fn) |
| 175 | #define subsys_initcall(fn) module_init(fn) |
| 176 | #define fs_initcall(fn) module_init(fn) |
| 177 | #define device_initcall(fn) module_init(fn) |
| 178 | #define late_initcall(fn) module_init(fn) |
| 179 | |
| 180 | #define security_initcall(fn) module_init(fn) |
| 181 | |
| 182 | #define module_init(initfn) \ |
| 183 | static inline initcall_t __inittest(void) \ |
| 184 | { return initfn; } \ |
| 185 | int init_module(void) __attribute__((alias(#initfn))); |
| 186 | |
| 187 | #define module_exit(exitfn) \ |
| 188 | static inline exitcall_t __exittest(void) \ |
| 189 | { return exitfn; } \ |
| 190 | void cleanup_module(void) __attribute__((alias(#exitfn))); |
| 191 | |
| 192 | #define __setup_param(str, unique_id, fn) |
| 193 | #define __setup(str, func) |
| 194 | #endif |
| 195 | |
| 196 | #define __nosavedata __section(.data..nosave) |
| 197 | |
| 198 | #ifdef CONFIG_MODULES |
| 199 | #define __init_or_module |
| 200 | #define __initdata_or_module |
| 201 | #define __initconst_or_module |
| 202 | #define __INIT_OR_MODULE .text |
| 203 | #define __INITDATA_OR_MODULE .data |
| 204 | #define __INITRODATA_OR_MODULE .section ".rodata","a",%progbits |
| 205 | #else |
| 206 | #define __init_or_module __init |
| 207 | #define __initdata_or_module __initdata |
| 208 | #define __initconst_or_module __initconst |
| 209 | #define __INIT_OR_MODULE __INIT |
| 210 | #define __INITDATA_OR_MODULE __INITDATA |
| 211 | #define __INITRODATA_OR_MODULE __INITRODATA |
| 212 | #endif |
| 213 | |
| 214 | #if defined(MODULE) || defined(CONFIG_HOTPLUG) |
| 215 | #define __devexit_p(x) x |
| 216 | #else |
| 217 | #define __devexit_p(x) NULL |
| 218 | #endif |
| 219 | |
| 220 | #ifdef MODULE |
| 221 | #define __exit_p(x) x |
| 222 | #else |
| 223 | #define __exit_p(x) NULL |
| 224 | #endif |
| 225 | |
| 226 | #endif |