| 1 | #ifndef _LINUX_INIT_H
|
|---|
| 2 | #define _LINUX_INIT_H
|
|---|
| 3 |
|
|---|
| 4 | #include <asm/errno.h>
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 | /* These macros are used to mark some functions or
|
|---|
| 8 | * initialized data (doesn't apply to uninitialized data)
|
|---|
| 9 | * as `initialization' functions. The kernel can take this
|
|---|
| 10 | * as hint that the function is used only during the initialization
|
|---|
| 11 | * phase and free up used memory resources after
|
|---|
| 12 | *
|
|---|
| 13 | * Usage:
|
|---|
| 14 | * For functions:
|
|---|
| 15 | *
|
|---|
| 16 | * You should add __init immediately before the function name, like:
|
|---|
| 17 | *
|
|---|
| 18 | * static void __init initme(int x, int y)
|
|---|
| 19 | * {
|
|---|
| 20 | * extern int z; z = x * y;
|
|---|
| 21 | * }
|
|---|
| 22 | *
|
|---|
| 23 | * If the function has a prototype somewhere, you can also add
|
|---|
| 24 | * __init between closing brace of the prototype and semicolon:
|
|---|
| 25 | *
|
|---|
| 26 | * extern int initialize_foobar_device(int, int, int) __init;
|
|---|
| 27 | *
|
|---|
| 28 | * For initialized data:
|
|---|
| 29 | * You should insert __initdata between the variable name and equal
|
|---|
| 30 | * sign followed by value, e.g.:
|
|---|
| 31 | *
|
|---|
| 32 | * static int init_variable __initdata = 0;
|
|---|
| 33 | * static char linux_logo[] __initdata = { 0x32, 0x36, ... };
|
|---|
| 34 | *
|
|---|
| 35 | * For initialized data not at file scope, i.e. within a function,
|
|---|
| 36 | * you should use __initlocaldata instead, due to a bug in GCC 2.7.
|
|---|
| 37 | */
|
|---|
| 38 |
|
|---|
| 39 | #ifndef MODULE
|
|---|
| 40 |
|
|---|
| 41 | #ifndef __ASSEMBLY__
|
|---|
| 42 |
|
|---|
| 43 | /*
|
|---|
| 44 | * Used for kernel command line parameter setup
|
|---|
| 45 | */
|
|---|
| 46 | struct kernel_param {
|
|---|
| 47 | const char *str;
|
|---|
| 48 | int (*setup_func)(char *);
|
|---|
| 49 | };
|
|---|
| 50 |
|
|---|
| 51 | extern struct kernel_param __setup_start, __setup_end;
|
|---|
| 52 |
|
|---|
| 53 | #define __setup(str, fn) \
|
|---|
| 54 | static char __setup_str_##fn[] __initdata = str; \
|
|---|
| 55 | static struct kernel_param __setup_##fn __initsetup = { __setup_str_##fn, fn }
|
|---|
| 56 |
|
|---|
| 57 | #endif /* __ASSEMBLY__ */
|
|---|
| 58 |
|
|---|
| 59 | /*
|
|---|
| 60 | * Used for initialization calls..
|
|---|
| 61 | */
|
|---|
| 62 | typedef int (*initcall_t)(void);
|
|---|
| 63 | typedef void (*exitcall_t)(void);
|
|---|
| 64 |
|
|---|
| 65 | #define __initcall(fn) \
|
|---|
| 66 | initcall_t __initcall_##fn = fn
|
|---|
| 67 |
|
|---|
| 68 | #define __exitcall(fn) \
|
|---|
| 69 | exitcall_t __exitcall_##fn = fn
|
|---|
| 70 |
|
|---|
| 71 |
|
|---|
| 72 | /*
|
|---|
| 73 | * Mark functions and data as being only used at initialization
|
|---|
| 74 | * or exit time.
|
|---|
| 75 | */
|
|---|
| 76 | #define __init
|
|---|
| 77 | #define __exit
|
|---|
| 78 | #define __initdata
|
|---|
| 79 | #define __exitdata
|
|---|
| 80 | #define __initsetup
|
|---|
| 81 | //#define __init_call
|
|---|
| 82 | #define __devinitdata
|
|---|
| 83 | #define __devinit
|
|---|
| 84 | #define __devexit
|
|---|
| 85 |
|
|---|
| 86 | /* For assembly routines */
|
|---|
| 87 | #define __INIT
|
|---|
| 88 | #define __FINIT
|
|---|
| 89 | #define __INITDATA
|
|---|
| 90 |
|
|---|
| 91 | #define module_init(x) __initcall(x);
|
|---|
| 92 | #define module_exit(x) __exitcall(x);
|
|---|
| 93 |
|
|---|
| 94 | #define extern_module_init(x) extern initcall_t __initcall_##x;
|
|---|
| 95 | #define extern_module_exit(x) extern exitcall_t __exitcall_##x;
|
|---|
| 96 |
|
|---|
| 97 | #else
|
|---|
| 98 |
|
|---|
| 99 | #define __init
|
|---|
| 100 | #define __exit
|
|---|
| 101 | #define __initdata
|
|---|
| 102 | #define __exitdata
|
|---|
| 103 | //#define __initcall
|
|---|
| 104 | /* For assembly routines */
|
|---|
| 105 | #define __INIT
|
|---|
| 106 | #define __FINIT
|
|---|
| 107 | #define __INITDATA
|
|---|
| 108 | #define __devinitdata
|
|---|
| 109 | #define __devinit
|
|---|
| 110 | #define __devexit
|
|---|
| 111 |
|
|---|
| 112 | /*
|
|---|
| 113 | * Used for initialization calls..
|
|---|
| 114 | */
|
|---|
| 115 | typedef int (*initcall_t)(void);
|
|---|
| 116 | typedef void (*exitcall_t)(void);
|
|---|
| 117 |
|
|---|
| 118 | #define __initcall(fn) \
|
|---|
| 119 | initcall_t __initcall_##fn = fn
|
|---|
| 120 |
|
|---|
| 121 | #define __exitcall(fn) \
|
|---|
| 122 | exitcall_t __exitcall_##fn = fn
|
|---|
| 123 |
|
|---|
| 124 |
|
|---|
| 125 | #define module_init(x) __initcall(x);
|
|---|
| 126 | #define module_exit(x) __exitcall(x);
|
|---|
| 127 |
|
|---|
| 128 | #define extern_module_init(x) extern initcall_t __initcall_##x;
|
|---|
| 129 | #define extern_module_exit(x) extern exitcall_t __exitcall_##x;
|
|---|
| 130 |
|
|---|
| 131 | #define __setup(str,func) /* nothing */
|
|---|
| 132 |
|
|---|
| 133 | #endif
|
|---|
| 134 |
|
|---|
| 135 | #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8)
|
|---|
| 136 | #define __initlocaldata __initdata
|
|---|
| 137 | #else
|
|---|
| 138 | #define __initlocaldata
|
|---|
| 139 | #endif
|
|---|
| 140 |
|
|---|
| 141 | #define __devexit_p(x) x
|
|---|
| 142 |
|
|---|
| 143 | /* subsys_initcall() wrapper */
|
|---|
| 144 | #define subsys_initcall(x) module_init(x)
|
|---|
| 145 | #define __init
|
|---|
| 146 | #endif /* _LINUX_INIT_H */
|
|---|