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