1 #ifndef _LINUX_INIT_H 2 #define _LINUX_INIT_H 3 4 /* 5 * Mark functions and data as being only used at initialization 6 * or exit time. 7 */ 8 #define __init __text_section(".init.text") 9 #define __exit __text_section(".exit.text") 10 #define __cold __text_section(".text.cold") 11 #define __initdata __section(".init.data") 12 #define __initconst __section(".init.rodata") 13 #define __initconstrel __section(".init.rodata.rel") 14 #define __exitdata __used_section(".exit.data") 15 #define __initsetup __used_section(".init.setup") 16 #define __init_call(lvl) __used_section(".initcall" lvl ".init") 17 #define __exit_call __used_section(".exitcall.exit") 18 19 #define __initdata_cf_clobber __section(".init.data.cf_clobber") 20 #define __initconst_cf_clobber __section(".init.rodata.cf_clobber") 21 22 /* These macros are used to mark some functions or 23 * initialized data (doesn't apply to uninitialized data) 24 * as `initialization' functions. The kernel can take this 25 * as hint that the function is used only during the initialization 26 * phase and free up used memory resources after 27 * 28 * Usage: 29 * For functions: 30 * 31 * You should add __init immediately before the function name, like: 32 * 33 * static void __init initme(int x, int y) 34 * { 35 * extern int z; z = x * y; 36 * } 37 * 38 * If the function has a prototype somewhere, you can also add 39 * __init between closing brace of the prototype and semicolon: 40 * 41 * extern int initialize_foobar_device(int, int, int) __init; 42 * 43 * For initialized data: 44 * You should insert __initdata between the variable name and equal 45 * sign followed by value, e.g.: 46 * 47 * static int init_variable __initdata = 0; 48 * static char linux_logo[] __initdata = { 0x32, 0x36, ... }; 49 * 50 * Don't forget to initialize data not at file scope, i.e. within a function, 51 * as gcc otherwise puts the data into the bss section and not into the init 52 * section. 53 * 54 * Also note, that this data cannot be "const". 55 */ 56 57 #ifndef __ASSEMBLY__ 58 59 /* 60 * Used for initialization calls.. 61 */ 62 typedef int (*initcall_t)(void); 63 typedef void (*exitcall_t)(void); 64 65 #define presmp_initcall(fn) \ 66 const static initcall_t __initcall_##fn __init_call("presmp") = (fn) 67 #define __initcall(fn) \ 68 const static initcall_t __initcall_##fn __init_call("1") = (fn) 69 #define __exitcall(fn) \ 70 static exitcall_t __exitcall_##fn __exit_call = fn 71 72 void do_presmp_initcalls(void); 73 void do_initcalls(void); 74 75 #endif /* __ASSEMBLY__ */ 76 77 #ifdef CONFIG_LATE_HWDOM 78 #define __hwdom_init 79 #define __hwdom_initdata __read_mostly 80 #else 81 #define __hwdom_init __init 82 #define __hwdom_initdata __initdata 83 #endif 84 85 #endif /* _LINUX_INIT_H */ 86