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